动画列表在 Android 5.0 (Lollipop) 中不起作用
animation-list not working in Android 5.0 (Lollipop)
我需要一个显示 3 点加载的简单动画。所以我创建了 3 个图像,将其添加到动画列表并将其设置为 imageview。它在 kitkat 之前工作正常,但在将我的 OS 更新为 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 a View
object. Then, call start()
to run the animation.
您需要调用 start()
来 运行 动画。
final ImageView myView = (ImageView) findViewById(R.id.dotsLoadingView);
((Animatable) myView.getDrawable()).start();
我需要一个显示 3 点加载的简单动画。所以我创建了 3 个图像,将其添加到动画列表并将其设置为 imageview。它在 kitkat 之前工作正常,但在将我的 OS 更新为 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();