Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7bde58a4
authored
Aug 17, 2017
by
Bei Yi
Committed by
Oliver Woodman
Sep 09, 2017
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Support crop mode for AspectRatioFrameLayout
parent
85d6c0f0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletions
library/ui/src/main/java/com/google/android/exoplayer2/ui/AspectRatioFrameLayout.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/AspectRatioFrameLayout.java
View file @
7bde58a4
...
@@ -32,7 +32,7 @@ public final class AspectRatioFrameLayout extends FrameLayout {
...
@@ -32,7 +32,7 @@ public final class AspectRatioFrameLayout extends FrameLayout {
* Resize modes for {@link AspectRatioFrameLayout}.
* Resize modes for {@link AspectRatioFrameLayout}.
*/
*/
@Retention
(
RetentionPolicy
.
SOURCE
)
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
RESIZE_MODE_FIT
,
RESIZE_MODE_FIXED_WIDTH
,
RESIZE_MODE_FIXED_HEIGHT
,
RESIZE_MODE_FILL
})
@IntDef
({
RESIZE_MODE_FIT
,
RESIZE_MODE_FIXED_WIDTH
,
RESIZE_MODE_FIXED_HEIGHT
,
RESIZE_MODE_FILL
,
RESIZE_MODE_CROP
})
public
@interface
ResizeMode
{}
public
@interface
ResizeMode
{}
/**
/**
...
@@ -51,6 +51,10 @@ public final class AspectRatioFrameLayout extends FrameLayout {
...
@@ -51,6 +51,10 @@ public final class AspectRatioFrameLayout extends FrameLayout {
* The specified aspect ratio is ignored.
* The specified aspect ratio is ignored.
*/
*/
public
static
final
int
RESIZE_MODE_FILL
=
3
;
public
static
final
int
RESIZE_MODE_FILL
=
3
;
/**
* The height or width is increased or decreased to crop and to obtain the desired aspect ratio.
*/
public
static
final
int
RESIZE_MODE_CROP
=
4
;
/**
/**
* The {@link FrameLayout} will not resize itself if the fractional difference between its natural
* The {@link FrameLayout} will not resize itself if the fractional difference between its natural
...
@@ -97,6 +101,15 @@ public final class AspectRatioFrameLayout extends FrameLayout {
...
@@ -97,6 +101,15 @@ public final class AspectRatioFrameLayout extends FrameLayout {
}
}
/**
/**
* Gets the resize mode.
*
* @return The resize mode.
*/
public
int
getResizeMode
()
{
return
this
.
resizeMode
;
}
/**
* Sets the resize mode.
* Sets the resize mode.
*
*
* @param resizeMode The resize mode.
* @param resizeMode The resize mode.
...
@@ -132,6 +145,13 @@ public final class AspectRatioFrameLayout extends FrameLayout {
...
@@ -132,6 +145,13 @@ public final class AspectRatioFrameLayout extends FrameLayout {
case
RESIZE_MODE_FIXED_HEIGHT:
case
RESIZE_MODE_FIXED_HEIGHT:
width
=
(
int
)
(
height
*
videoAspectRatio
);
width
=
(
int
)
(
height
*
videoAspectRatio
);
break
;
break
;
case
RESIZE_MODE_CROP:
if
(
videoAspectRatio
>
viewAspectRatio
)
{
width
=
(
int
)
(
height
*
videoAspectRatio
);
}
else
{
height
=
(
int
)
(
width
/
videoAspectRatio
);
}
break
;
default
:
default
:
if
(
aspectDeformation
>
0
)
{
if
(
aspectDeformation
>
0
)
{
height
=
(
int
)
(
width
/
videoAspectRatio
);
height
=
(
int
)
(
width
/
videoAspectRatio
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment