InsetDrawable
open class InsetDrawable : DrawableWrapper
| kotlin.Any | |||
| ↳ | android.graphics.drawable.Drawable | ||
| ↳ | android.graphics.drawable.DrawableWrapper | ||
| ↳ | android.graphics.drawable.InsetDrawable | ||
A Drawable that insets another Drawable by a specified distance or fraction of the content bounds. This is used when a View needs a background that is smaller than the View's actual bounds.
It can be defined in an XML file with the <inset> element. For more information, see the guide to Drawable Resources.
The inset values are added to the padding of the view. For instance, if a view has a padding of 10 pixels on all sides and an InsetDrawable with an inset of 5 pixels is set as its background, the effective padding of the view will be 15 pixels on all sides.
Note: When using fractional insets (floats), the intrinsic size calculation is influenced by insets on opposite sides. For example, applying a fractional inset to only the bottom of a drawable may also affect the drawable's top padding. For insets that should only affect a single side, using dimension-based insets (integers) will provide that behavior.
Summary
| XML attributes | |
|---|---|
android:drawable |
Reference to a drawable resource to use for the frame. |
android:insetBottom |
|
android:insetLeft |
|
android:insetRight |
|
android:insetTop |
|
android:visible |
Provides initial visibility state of the drawable; the default value is false. |
| Public constructors | |
|---|---|
InsetDrawable(drawable: Drawable?, inset: Float)Creates a new inset drawable with the specified inset. |
|
InsetDrawable(drawable: Drawable?, insetLeftFraction: Float, insetTopFraction: Float, insetRightFraction: Float, insetBottomFraction: Float)Creates a new inset drawable with the specified insets in fraction of the view bounds. |
|
InsetDrawable(drawable: Drawable?, inset: Int)Creates a new inset drawable with the specified inset. |
|
InsetDrawable(drawable: Drawable?, insetLeft: Int, insetTop: Int, insetRight: Int, insetBottom: Int)Creates a new inset drawable with the specified insets in pixels. |
|
| Public methods | |
|---|---|
| open Unit |
Applies the specified theme to this Drawable and its children. |
| open Int |
Returns the drawable's intrinsic height. |
| open Int |
Returns the drawable's intrinsic width. |
| open Int |
Return the opacity/transparency of this Drawable. |
| open Insets |
Return in insets the layout insets suggested by this Drawable for use with alignment operations during layout. |
| open Unit |
getOutline(outline: Outline)Called to get the drawable to populate the Outline that defines its drawing area. |
| open Boolean |
getPadding(padding: Rect)Returns in |
| open Unit |
inflate(r: Resources, parser: XmlPullParser, attrs: AttributeSet, theme: Resources.Theme?)Inflate this Drawable from an XML resource optionally styled by a theme. |
| Protected methods | |
|---|---|
| open Unit |
onBoundsChange(bounds: Rect)Override this in your subclass to change appearance if you vary based on the bounds. |
| Inherited functions | |
|---|---|