Android.Graphics.Drawables.LevelListDrawable Class
A resource that manages a number of alternate Drawables, each assigned a maximum numerical value.

See Also: LevelListDrawable Members

Syntax

[Android.Runtime.Register("android/graphics/drawable/LevelListDrawable", DoNotGenerateAcw=true)]
public class LevelListDrawable : DrawableContainer

Remarks

A resource that manages a number of alternate Drawables, each assigned a maximum numerical value. Setting the level value of the object with Drawable.SetLevel(int) will load the image with the next greater or equal value assigned to its max attribute. A good example use of a LevelListDrawable would be a battery level indicator icon, with different images to indicate the current battery level.

xml Example

 <level-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:maxLevel="0" android:drawable="@drawable/ic_wifi_signal_1" />
  <item android:maxLevel="1" android:drawable="@drawable/ic_wifi_signal_2" />
  <item android:maxLevel="2" android:drawable="@drawable/ic_wifi_signal_3" />
  <item android:maxLevel="3" android:drawable="@drawable/ic_wifi_signal_4" />
 </level-list>

It can be defined in an XML file with the <level-list> element. Each Drawable level is defined in a nested <item>. For example:

With this XML saved into the res/drawable/ folder of the project, it can be referenced as the drawable for an Android.Widget.ImageView. The default image is the first in the list. It can then be changed to one of the other levels with Android.Widget.ImageView.SetImageLevel(int). For more information, see the guide to Drawable Resources.

[Android Documentation]

Requirements

Namespace: Android.Graphics.Drawables
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1