StateListDrawableCompat

class StateListDrawableCompat : DrawableContainerCompat

Known direct subclasses
AnimatedStateListDrawableCompat

A Drawable providing animated transitions between states.


Lets you assign a number of graphic images to a single Drawable and swap out the visible item by a string ID value.

It can be defined in an XML file with the <selector> element. Each state Drawable is defined in a nested <item> element. For more information, see the guide to Drawable Resources. visiblevariablePaddingconstantSizestate_focusedstate_window_focusedstate_enabledstate_checkablestate_checkedstate_selectedstate_activatedstate_activestate_singlestate_firststate_middlestate_laststate_pressed

Adapted from platform class; altered with API level checks as necessary &uses ResourceManagerInternal for Drawable inflation.

Summary

Public constructors

Creates an empty state list drawable.

Public functions

Unit
addState(stateSet: IntArray!, drawable: Drawable!)

Add a new image/string ID to the set of images.

Unit
@RequiresApi(value = 21)
applyTheme(theme: Resources.Theme)
Unit
inflate(
    context: Context,
    r: Resources,
    parser: XmlPullParser,
    attrs: AttributeSet,
    theme: Resources.Theme?
)

Inflate this Drawable from an XML resource optionally styled by a theme.

Boolean
Drawable

Protected functions

Boolean

Inherited functions

From android.graphics.drawable.Drawable
Unit
Boolean
Unit
Rect!
Unit
copyBounds(bounds: Rect!)
java-static Drawable!
createFromPath(pathName: String!)
java-static Drawable!
createFromResourceStream(
    res: Resources!,
    value: TypedValue!,
    is: InputStream!,
    srcName: String!
)
java-static Drawable!
createFromStream(is: InputStream!, srcName: String!)
java-static Drawable!
java-static Drawable!
createFromXmlInner(
    r: Resources!,
    parser: XmlPullParser!,
    attrs: AttributeSet!
)
abstract Unit
draw(p: Canvas!)
Int
Rect!
Drawable.Callback!
Int
ColorFilter!
Drawable.ConstantState!
Drawable!
Rect!
Unit
Int
Int
Int
Int
Int
Int
abstract Int

This function is deprecated.

Insets!
Unit
getOutline(outline: Outline!)
Boolean
getPadding(padding: Rect!)
IntArray<Int>!
Region!
Boolean
Unit
inflate(r: Resources!, parser: XmlPullParser!, attrs: AttributeSet!)
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Drawable!
Unit
onBoundsChange(bounds: Rect!)
Boolean
onLayoutDirectionChanged(layoutDirection: Int)
Boolean
Boolean
java-static Int
resolveOpacity(op1: Int, op2: Int)
Unit
scheduleSelf(what: Runnable!, when: Long)
abstract Unit
Unit
Unit
setBounds(left: Int, top: Int, right: Int, bottom: Int)
Unit
Unit
abstract Unit
Unit
setDither(dither: Boolean)

This function is deprecated.

Unit
Unit
Unit
setHotspotBounds(left: Int, top: Int, right: Int, bottom: Int)
Boolean
setLayoutDirection(layoutDirection: Int)
Boolean
setLevel(level: Int)
Boolean
setState(stateSet: IntArray!)
Unit
setTint(tintColor: Int)
Unit
Unit
Unit
Boolean
setVisible(visible: Boolean, restart: Boolean)
Unit
From android.graphics.drawable.Drawable.Callback
abstract Unit
abstract Unit
scheduleDrawable(p: Drawable!, p1: Runnable!, p2: Long)
abstract Unit
From androidx.appcompat.graphics.drawable.DrawableContainerCompat
Boolean
@RequiresApi(value = 21)
canApplyTheme()
Unit
draw(canvas: Canvas)
Int
Int
Drawable.ConstantState!
Drawable
Unit
Int
Int
Int
Int
Int

This function is deprecated.

Unit
@RequiresApi(value = 21)
getOutline(outline: Outline)
Boolean
getPadding(padding: Rect)
Unit
Boolean
Unit
Unit
onBoundsChange(bounds: Rect!)
Boolean
onLayoutDirectionChanged(layoutDirection: Int)
Boolean
Unit
scheduleDrawable(who: Drawable, what: Runnable, when: Long)
Unit
setAlpha(alpha: Int)
Unit
Unit
setColorFilter(colorFilter: ColorFilter!)
Unit
setDither(dither: Boolean)

This function is deprecated.

Unit

Change the global fade duration when a new drawable is entering the scene.

Unit

Change the global fade duration when a new drawable is leaving the scene.

Unit
Unit
setHotspotBounds(left: Int, top: Int, right: Int, bottom: Int)
Unit
setTint(tintColor: @ColorInt Int)
Unit
Unit
Boolean
setVisible(visible: Boolean, restart: Boolean)
Unit

Public constructors

StateListDrawableCompat

Added in 1.6.0
StateListDrawableCompat()

Creates an empty state list drawable.

Public functions

addState

Added in 1.6.0
fun addState(stateSet: IntArray!, drawable: Drawable!): Unit

Add a new image/string ID to the set of images.

Parameters
stateSet: IntArray!

- An array of resource Ids to associate with the image. Switch to this image by calling setState().

drawable: Drawable!

-The image to show.

applyTheme

@RequiresApi(value = 21)
fun applyTheme(theme: Resources.Theme): Unit

inflate

Added in 1.6.0
fun inflate(
    context: Context,
    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.

Parameters
r: Resources

Resources used to resolve attribute values

parser: XmlPullParser

XML parser from which to inflate this Drawable

attrs: AttributeSet

Base set of attribute values

theme: Resources.Theme?

Theme to apply, may be null

isStateful

fun isStateful(): Boolean

mutate

fun mutate(): Drawable

Protected functions

onStateChange

protected fun onStateChange(stateSet: IntArray): Boolean