android - 动画列表在 Android 5.0 (Lollipop) 中不起作用

标签 android animation android-5.0-lollipop

我需要一个显示 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 a View object. Then, call start() 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/

相关文章:

android - @+android :id? 是否有任何合法用途

android - 删除幻灯片窗口转换在启动时创建的白屏

android - 如何在我的应用程序的文件资源管理器文件夹中添加应用程序图标

android - 如何创建导致非启动器 Activity 的快捷方式?

android - 进入 android 网络,HTTP 库首选项?

jquery - 将动画添加到自举 Accordion 中,同时保持适当的加减号

swift - 旋转动画仅在最终位置显示 iOS swift

design-patterns - 什么是复杂动画的好的抽象?

android - 如何使用字体文件中的图标作为 Android 中的可绘制对象

android - Android-具有LiveData的DataBinding保留旧值