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.
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 | |
open Int | |
open Int | |
open Insets | |
open Unit |
getOutline(outline: Outline) Called to get the drawable to populate the Outline that defines its drawing area. |
open Boolean |
getPadding(padding: Rect) |
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) |
Inherited functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
XML attributes
android:drawable
android:drawable
May be a reference to another resource, in the form "@[+][package:]type/name
" or a theme attribute in the form "?[package:]type/name
".
android:insetBottom
android:insetBottom
android:insetLeft
android:insetLeft
android:insetRight
android:insetRight
android:insetTop
android:insetTop
android:visible
android:visible
android.graphics.drawable.Drawable#setVisible
.
May be a boolean value, such as "true
" or "false
".
Public constructors
InsetDrawable
InsetDrawable(
drawable: Drawable?,
inset: Float)
Creates a new inset drawable with the specified inset.
InsetDrawable
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.
Parameters | |
---|---|
drawable |
Drawable?: The drawable to inset. This value may be null . |
insetLeftFraction |
Float: Left inset in fraction (range: [0, 1)) of the inset content bounds. |
insetTopFraction |
Float: Top inset in fraction (range: [0, 1)) of the inset content bounds. |
insetRightFraction |
Float: Right inset in fraction (range: [0, 1)) of the inset content bounds. |
insetBottomFraction |
Float: Bottom inset in fraction (range: [0, 1)) of the inset content bounds. |
InsetDrawable
InsetDrawable(
drawable: Drawable?,
inset: Int)
Creates a new inset drawable with the specified inset.
InsetDrawable
InsetDrawable(
drawable: Drawable?,
insetLeft: Int,
insetTop: Int,
insetRight: Int,
insetBottom: Int)
Creates a new inset drawable with the specified insets in pixels.
Public methods
applyTheme
open fun applyTheme(t: Resources.Theme): Unit
Applies the specified theme to this Drawable and its children.
Parameters | |
---|---|
t |
Resources.Theme: This value cannot be null . |
getIntrinsicHeight
open fun getIntrinsicHeight(): Int
Return | |
---|---|
Int |
the intrinsic height, or -1 if no intrinsic height |
getIntrinsicWidth
open fun getIntrinsicWidth(): Int
Return | |
---|---|
Int |
the intrinsic width, or -1 if no intrinsic width |
getOpacity
open fun getOpacity(): Int
Return | |
---|---|
Int |
int The opacity class of the Drawable. Value is android.graphics.PixelFormat#UNKNOWN , android.graphics.PixelFormat#TRANSLUCENT , android.graphics.PixelFormat#TRANSPARENT , or android.graphics.PixelFormat#OPAQUE |
getOpticalInsets
open fun getOpticalInsets(): Insets
Return | |
---|---|
Insets |
This value cannot be null . |
getOutline
open fun getOutline(outline: Outline): Unit
Called to get the drawable to populate the Outline that defines its drawing area.
This method is called by the default android.view.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.
Parameters | |
---|---|
outline |
Outline: This value cannot be null . |
getPadding
open fun getPadding(padding: Rect): Boolean
Parameters | |
---|---|
padding |
Rect: This value cannot be null . |
Return | |
---|---|
Boolean |
true if this drawable actually has a padding, else false. When false is returned, the padding is always set to 0. |
inflate
open fun inflate(
r: Resources,
parser: XmlPullParser,
attrs: AttributeSet,
theme: Resources.Theme?
): Unit
Inflate this Drawable from an XML resource optionally styled by a theme. This can't be called more than once for each Drawable. Note that framework may have called this once to create the Drawable instance from XML resource.
Parameters | |
---|---|
r |
Resources: This value cannot be null . |
parser |
XmlPullParser: This value cannot be null . |
attrs |
AttributeSet: This value cannot be null . |
theme |
Resources.Theme?: This value may be null . |
Exceptions | |
---|---|
org.xmlpull.v1.XmlPullParserException |
|
java.io.IOException |
Protected methods
onBoundsChange
protected open fun onBoundsChange(bounds: Rect): Unit
Parameters | |
---|---|
bounds |
Rect: This value cannot be null . |