Level List Drawables

Using a Level List Drawable you can effectively overlay several Drawable resources, specifying an integer index value for each layer, as shown in Listing 4-23.

LISTING 4-23: Level List Drawable resource

LISTING 4-23: Level List Drawable resource

<level-list xmlns:android: <item android:maxLevel= <item android:maxLevel= <item android:maxLevel= <item android:maxLevel= <item android:maxLevel= <item android:maxLevel= <item android:maxLevel= </level-list>

="http://schemas.android.com/apk/res/android">

0" android:drawable="@drawable/earthquake_0"/>

1" android:drawable="@drawable/earthquake_1"/>

2" android:drawable="@drawable/earthquake_2"/>

4" android:drawable="@drawable/earthquake_4"/>

6" android:drawable="@drawable/earthquake_6"/>

8" android:drawable="@drawable/earthquake_8"/>

10" android:drawable="@drawable/earthquake_10"/>

To select which image to display in code call setimageLevel on the View displaying the Level List Drawable resource, passing in the index of the Drawable you wish to display.

imageView.setImageLevel(5);

The View will display the image corresponding to the index with an equal or greater value to the one specified. Level List Drawables are particularly useful when creating Widget layouts.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Responses

  • GABRIELE SCHROEDER
    How to use levellist drawable?
    7 years ago

Post a comment