public class InsetDrawable extends DrawableWrapper
It can be defined in an XML file with the <inset>
element. For more
information, see the guide to Drawable Resources.
Drawable.Callback, Drawable.ConstantState
Constructor and Description |
---|
InsetDrawable(Drawable drawable,
int inset)
Creates a new inset drawable with the specified inset.
|
InsetDrawable(Drawable drawable,
int insetLeft,
int insetTop,
int insetRight,
int insetBottom)
Creates a new inset drawable with the specified insets.
|
Modifier and Type | Method and Description |
---|---|
void |
applyTheme(Resources.Theme t)
Applies the specified theme to this Drawable and its children.
|
int |
getIntrinsicHeight()
Returns the drawable's intrinsic height.
|
int |
getIntrinsicWidth()
Returns the drawable's intrinsic width.
|
int |
getOpacity()
Return the opacity/transparency of this Drawable.
|
Insets |
getOpticalInsets()
Return in insets the layout insets suggested by this Drawable for use with alignment
operations during layout.
|
void |
getOutline(Outline outline)
Called to get the drawable to populate the Outline that defines its drawing area.
|
boolean |
getPadding(Rect padding)
Return in padding the insets suggested by this Drawable for placing
content inside the drawable's bounds.
|
void |
inflate(Resources r,
XmlPullParser parser,
AttributeSet attrs,
Resources.Theme theme)
Inflate this Drawable from an XML resource optionally styled by a theme.
|
protected void |
onBoundsChange(Rect bounds)
Override this in your subclass to change appearance if you vary based on
the bounds.
|
canApplyTheme, clearMutated, draw, getAlpha, getChangingConfigurations, getConstantState, getDrawable, getHotspotBounds, invalidateDrawable, isStateful, mutate, onLayoutDirectionChanged, onLevelChange, onStateChange, scheduleDrawable, setAlpha, setColorFilter, setDrawable, setHotspot, setHotspotBounds, setTintList, setTintMode, setVisible, unscheduleDrawable
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getBounds, getCallback, getColorFilter, getCurrent, getDirtyBounds, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getState, getTransparentRegion, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isProjected, isVisible, jumpToCurrentState, obtainAttributes, parseTintMode, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setLayoutDirection, setLevel, setState, setTint, setXfermode, unscheduleSelf
public InsetDrawable(Drawable drawable, int inset)
drawable
- The drawable to inset.inset
- Inset in pixels around the drawable.public InsetDrawable(Drawable drawable, int insetLeft, int insetTop, int insetRight, int insetBottom)
drawable
- The drawable to inset.insetLeft
- Left inset in pixels.insetTop
- Top inset in pixels.insetRight
- Right inset in pixels.insetBottom
- Bottom inset in pixels.public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme) throws XmlPullParserException, IOException
Drawable
inflate
in class DrawableWrapper
r
- Resources used to resolve attribute valuesparser
- XML parser from which to inflate this Drawableattrs
- Base set of attribute valuestheme
- Theme to apply, may be nullXmlPullParserException
IOException
public void applyTheme(Resources.Theme t)
Drawable
applyTheme
in class DrawableWrapper
t
- the theme to applypublic boolean getPadding(Rect padding)
Drawable
getPadding
in class DrawableWrapper
public Insets getOpticalInsets()
Drawable
getOpticalInsets
in class DrawableWrapper
public int getOpacity()
Drawable
PixelFormat
:
PixelFormat.UNKNOWN
,
PixelFormat.TRANSLUCENT
,
PixelFormat.TRANSPARENT
, or
PixelFormat.OPAQUE
.
An OPAQUE drawable is one that draws all all content within its bounds, completely covering anything behind the drawable. A TRANSPARENT drawable is one that draws nothing within its bounds, allowing everything behind it to show through. A TRANSLUCENT drawable is a drawable in any other state, where the drawable will draw some, but not all, of the content within its bounds and at least some content behind the drawable will be visible. If the visibility of the drawable's contents cannot be determined, the safest/best return value is TRANSLUCENT.
Generally a Drawable should be as conservative as possible with the
value it returns. For example, if it contains multiple child drawables
and only shows one of them at a time, if only one of the children is
TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be
returned. You can use the method Drawable.resolveOpacity(int, int)
to perform a
standard reduction of two opacities to the appropriate single output.
Note that the returned value does not necessarily take into account a
custom alpha or color filter that has been applied by the client through
the Drawable.setAlpha(int)
or Drawable.setColorFilter(android.graphics.ColorFilter)
methods. Some subclasses,
such as BitmapDrawable
, ColorDrawable
, and GradientDrawable
,
do account for the value of Drawable.setAlpha(int)
, but the general behavior is dependent
upon the implementation of the subclass.
getOpacity
in class DrawableWrapper
PixelFormat
protected void onBoundsChange(Rect bounds)
Drawable
onBoundsChange
in class DrawableWrapper
public int getIntrinsicWidth()
Drawable
Intrinsic width is the width at which the drawable would like to be laid out, including any inherent padding. If the drawable has no intrinsic width, such as a solid color, this method returns -1.
getIntrinsicWidth
in class DrawableWrapper
public int getIntrinsicHeight()
Drawable
Intrinsic height is the height at which the drawable would like to be laid out, including any inherent padding. If the drawable has no intrinsic height, such as a solid color, this method returns -1.
getIntrinsicHeight
in class DrawableWrapper
public void getOutline(Outline outline)
Drawable
This method is called by the default ViewOutlineProvider
to define
the outline of the View.
The default behavior defines the outline to be the bounding rectangle of 0 alpha. Subclasses that wish to convey a different shape or alpha value must override this method.
getOutline
in class DrawableWrapper
View.setOutlineProvider(android.view.ViewOutlineProvider)