A Drawable that manages a number of alternate Drawables, each assigned a maximum numerical value. Setting the level value of the drawable with setLevel()
loads the drawable resource in the level list that has aandroid:maxLevel
value greater than or equal to the value passed to the method.
-
file location:
-
res/drawable/filename.xml
The filename is used as the resource ID.
compiled resource datatype:
-
Resource pointer to a
LevelListDrawable
.
resource reference:
-
In Java:
R.drawable.filename
In XML:@[package:]drawable/filename
syntax:
-
<?xml version="1.0" encoding="utf-8"?> <level-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/drawable_resource" android:maxLevel="integer" android:minLevel="integer" /> </level-list>
elements:
- example:
-
<?xml version="1.0" encoding="utf-8"?> <level-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/status_off" android:maxLevel="0" /> <item android:drawable="@drawable/status_on" android:maxLevel="1" /> </level-list>
Once this is applied to a
View
, the level can be changed withsetLevel()
orsetImageLevel()
.