Android Guides | Samples

Android.Graphics.Drawables.LevelListDrawable Class

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

See Also: LevelListDrawable

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(Int32) 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 ImageView. The default image is the first in the list. It can then be changed to one of the other levels with ImageView.SetImageLevel(Int32). 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

The members of Android.Graphics.Drawables.LevelListDrawable are listed below.

See Also: DrawableContainer

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods