public final class Outline extends Object
Can be computed for a View, or computed by a Drawable, to drive the shape of shadows cast by a View, or to clip the contents of the View.
Modifier and Type | Class and Description |
---|---|
static interface |
Outline.Mode |
Modifier and Type | Field and Description |
---|---|
float |
mAlpha |
int |
mMode |
static int |
MODE_CONVEX_PATH |
static int |
MODE_EMPTY |
static int |
MODE_ROUND_RECT |
Path |
mPath |
float |
mRadius |
Rect |
mRect |
Constructor and Description |
---|
Outline()
Constructs an empty Outline.
|
Outline(Outline src)
Constructs an Outline with a copy of the data in src.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canClip()
Returns whether the outline can be used to clip a View.
|
float |
getAlpha()
Returns the alpha represented by the Outline.
|
float |
getRadius()
Returns the rounded rect radius, if set, or a value less than 0 if a path has
been set via
setConvexPath(Path) . |
boolean |
getRect(Rect outRect)
Populates
outBounds with the outline bounds, if set, and returns
true . |
boolean |
isEmpty()
Returns whether the Outline is empty.
|
void |
offset(int dx,
int dy)
Offsets the Outline by (dx,dy)
|
void |
set(Outline src)
Replace the contents of this Outline with the contents of src.
|
void |
setAlpha(float alpha)
Sets the alpha represented by the Outline - the degree to which the
producer is guaranteed to be opaque over the Outline's shape.
|
void |
setConvexPath(Path convexPath)
Sets the Constructs an Outline from a
convex path . |
void |
setEmpty()
Sets the outline to be empty.
|
void |
setOval(int left,
int top,
int right,
int bottom)
Sets the outline to the oval defined by input rect.
|
void |
setOval(Rect rect)
Convenience for
setOval(int, int, int, int) |
void |
setRect(int left,
int top,
int right,
int bottom)
Sets the Outline to the rounded rect defined by the input rect, and
corner radius.
|
void |
setRect(Rect rect)
Convenience for
setRect(int, int, int, int) |
void |
setRoundRect(int left,
int top,
int right,
int bottom,
float radius)
Sets the Outline to the rounded rect defined by the input rect, and corner radius.
|
void |
setRoundRect(Rect rect,
float radius)
Convenience for
setRoundRect(int, int, int, int, float) |
public static final int MODE_EMPTY
public static final int MODE_ROUND_RECT
public static final int MODE_CONVEX_PATH
public int mMode
public final Path mPath
public final Rect mRect
public float mRadius
public float mAlpha
public Outline()
public Outline(Outline src)
public void setEmpty()
isEmpty()
public boolean isEmpty()
Outlines are empty when constructed, or if setEmpty()
is called,
until a setter method is called
setEmpty()
public boolean canClip()
Currently, only Outlines that can be represented as a rectangle, circle, or round rect support clipping.
android.view.View#setClipToOutline(boolean)}
public void setAlpha(float alpha)
An alpha value of 0.0f
either represents completely
transparent content, or content that isn't guaranteed to fill the shape
it publishes.
Content producing a fully opaque (alpha = 1.0f
) outline is
assumed by the drawing system to fully cover content beneath it,
meaning content beneath may be optimized away.
public float getAlpha()
public void set(Outline src)
src
- Source outline to copy from.public void setRect(int left, int top, int right, int bottom)
public void setRect(Rect rect)
setRect(int, int, int, int)
public void setRoundRect(int left, int top, int right, int bottom, float radius)
Passing a zero radius is equivalent to calling setRect(int, int, int, int)
public void setRoundRect(Rect rect, float radius)
setRoundRect(int, int, int, int, float)
public boolean getRect(Rect outRect)
outBounds
with the outline bounds, if set, and returns
true
. If no outline bounds are set, or if a path has been set
via setConvexPath(Path)
, returns false
.outRect
- the rect to populate with the outline bounds, if settrue
if outBounds
was populated with outline
bounds, or false
if no outline bounds are setpublic float getRadius()
setConvexPath(Path)
. A return value of 0
indicates a non-rounded rect.public void setOval(int left, int top, int right, int bottom)
public void setOval(Rect rect)
setOval(int, int, int, int)
public void setConvexPath(Path convexPath)
convex path
.public void offset(int dx, int dy)