动画列表可在Android 5上绘制为ImageView可绘制源

时间:2014-11-03 18:21:34

标签: android android-animation android-imageview

在Android 5下设置为图像视图的可绘制源时,是否存在以下动画无法播放的特定原因?

<?xml version="1.0" encoding="utf-8"?> <animation-list android:oneshot="false"   xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="750" android:drawable="@drawable/ic_status_battery_0" />
<item android:duration="750" android:drawable="@drawable/ic_status_battery_1" />
<item android:duration="750" android:drawable="@drawable/ic_status_battery_2" />
<item android:duration="750" android:drawable="@drawable/ic_status_battery_full" /> </animation-list>

在Android 4.4上完美运行。

1 个答案:

答案 0 :(得分:0)

好的,似乎对于嵌入在LevelListDrawable对象中的AnimationDrawable对象,在Android 5上只有以下方法:

LevelListDrawable lld = (LevelListDrawable) imageView.getDrawable();
Drawable current = lld.getCurrent();

if(current instanceof AnimationDrawable) {
    ((AnimationDrawable)current).start();
}