Outlinepublic final class Outline extends Object Defines a simple shape, used for bounding graphical regions.
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. |
Fields Summary |
---|
public Path | mPath | public Rect | mRect | public float | mRadius | public float | mAlpha |
Constructors Summary |
---|
public Outline()Constructs an empty Outline. Call one of the setter methods to make
the outline valid for use with a View.
| public Outline(Outline src)Constructs an Outline with a copy of the data in src.
set(src);
|
Methods Summary |
---|
public boolean | canClip()Returns whether the outline can be used to clip a View.
Currently, only Outlines that can be represented as a rectangle, circle,
or round rect support clipping.
return !isEmpty() && mRect != null;
| public float | getAlpha()Returns the alpha represented by the Outline.
return mAlpha;
| public boolean | isEmpty()Returns whether the Outline is empty.
Outlines are empty when constructed, or if {@link #setEmpty()} is called,
until a setter method is called
return mRect == null && mPath == null;
| public void | offset(int dx, int dy)Offsets the Outline by (dx,dy)
if (mRect != null) {
mRect.offset(dx, dy);
} else if (mPath != null) {
mPath.offset(dx, dy);
}
| public void | set(android.graphics.Outline src)Replace the contents of this Outline with the contents of src.
if (src.mPath != null) {
if (mPath == null) {
mPath = new Path();
}
mPath.set(src.mPath);
mRect = null;
}
if (src.mRect != null) {
if (mRect == null) {
mRect = new Rect();
}
mRect.set(src.mRect);
}
mRadius = src.mRadius;
mAlpha = src.mAlpha;
| public 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.
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.
mAlpha = alpha;
| public void | setConvexPath(Path convexPath)Sets the Constructs an Outline from a
{@link android.graphics.Path#isConvex() convex path}.
if (convexPath.isEmpty()) {
setEmpty();
return;
}
if (!convexPath.isConvex()) {
throw new IllegalArgumentException("path must be convex");
}
if (mPath == null) mPath = new Path();
mPath.set(convexPath);
mRect = null;
mRadius = -1.0f;
| public void | setEmpty()Sets the outline to be empty.
mPath = null;
mRect = null;
mRadius = 0;
| public void | setOval(int left, int top, int right, int bottom)Sets the outline to the oval defined by input rect.
if (left >= right || top >= bottom) {
setEmpty();
return;
}
if ((bottom - top) == (right - left)) {
// represent circle as round rect, for efficiency, and to enable clipping
setRoundRect(left, top, right, bottom, (bottom - top) / 2.0f);
return;
}
if (mPath == null) mPath = new Path();
mPath.reset();
mPath.addOval(left, top, right, bottom, Path.Direction.CW);
mRect = null;
| public void | setOval(Rect rect)Convenience for {@link #setOval(int, int, int, int)}
setOval(rect.left, rect.top, rect.right, rect.bottom);
| public void | setRect(Rect rect)Convenience for {@link #setRect(int, int, int, int)}
setRect(rect.left, rect.top, rect.right, rect.bottom);
| public 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.
setRoundRect(left, top, right, bottom, 0.0f);
| public 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.
Passing a zero radius is equivalent to calling {@link #setRect(int, int, int, int)}
if (left >= right || top >= bottom) {
setEmpty();
return;
}
if (mRect == null) mRect = new Rect();
mRect.set(left, top, right, bottom);
mRadius = radius;
mPath = null;
| public void | setRoundRect(Rect rect, float radius)Convenience for {@link #setRoundRect(int, int, int, int, float)}
setRoundRect(rect.left, rect.top, rect.right, rect.bottom, radius);
|
|