Drawable资源之LevelListDrawable资源

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:
<level-list>
This must be the root element. Contains one or more   <item>  elements.

attributes:

xmlns:android
String.   Required.  Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".
<item>
Defines a drawable to use at a certain level.

attributes:

android:drawable
Drawable resource.   Required. Reference to a drawable resource to be inset.
android:maxLevel
Integer. The maximum level allowed for this item.
android:minLevel
Integer. The minimum level allowed for this item.
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 with setLevel() or setImageLevel().

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值