我需要一个显示 3 点加载的简单动画。所以我创建了 3 个图像,将其添加到动画列表并将其设置为 imageview。它在 kitkat 之前工作正常,但在将我的操作系统更新为 Lollipop 之后,动画似乎无法正常工作。
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="@drawable/one_dot"
android:duration="500"/>
<item
android:drawable="@drawable/two_dot"
android:duration="500"/>
<item
android:drawable="@drawable/three_dot"
android:duration="500"/>
</animation-list>
这是它设置到 imageView 的方式
<ImageView
android:id="@+id/dotsLoadingView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/loadingText"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:src="@drawable/dots_loading" />
Android 5.0 Lollipop 的动画有什么变化吗?
最佳答案
来自documentation对于 AnimationDrawable,
The simplest way to create a frame-by-frame animation is to define the animation in an XML file, placed in the
res/drawable/
folder, and set it as the background to aView
object. Then, callstart()
to run the animation.
您需要调用start()
来运行动画。
final ImageView myView = (ImageView) findViewById(R.id.dotsLoadingView);
((Animatable) myView.getDrawable()).start();
关于android - 动画列表在 Android 5.0 (Lollipop) 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29073453/