开发者

declaring an animation on a drawable in XMl in android

Is there a way to set an animation on a drawable in XML in android? My specific case:

I have a level-list drawable where 1 level of that list should rotate continuously. I can do it fine in code when I set the level. But it would be so much easier if I could just set it in code.

So I have:

<level-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@drawable/unplugged_image"
        android:maxLevel="1"
        android:minLevel="1"/>
    <item
        android:maxLevel="2"
        android:minLevel="2"
        android:drawable="@drawable/plugged_image"/>
    <item
        android:maxLevel="3"
        android:minLevel="3"
        android:drawable="@drawable/charging_drawable"/> 
    <item
        android:drawable="@drawable/fault_image"
        android:maxLevel="0"
        android:minLevel="0" />
</level-list>

This is the drawable for "@drawable/charge_drawable"

<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <bitmap android:src="@drawable/charge_disc_image"
        android:gravity="center" />

    </item>
    <it开发者_运维问答em>
        <bitmap android:src="@drawable/charge_disc_inner" <!-- this is the image I want to have rotating -->
        android:gravity="center" />

    </item>
    <item>
        <bitmap android:src="@drwable/charge_disc_shine"
        android:gravity="center" />

    </item>


</layer-list>

Is there a way to set only the noted bitmap to have an automatic animation whenever it's displayed?


Unless you make the drawable in question a AnimationDrawable, I don't think what you want is possible, sorry.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜