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

Dee*_*ati 7 animation android 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>
Run Code Online (Sandbox Code Playgroud)

这是它如何设置为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" />
Run Code Online (Sandbox Code Playgroud)

关于Android 5.0 Lollipop动画有什么变化吗?

ala*_*anv 17

从AnimationDrawable 的文档中,

创建逐帧动画的最简单方法是在XML文件中定义动画,放置在res/drawable/文件夹中,并将其设置为View对象的背景.然后,调用start()以运行动画.

您需要调用start()以运行动画.

final ImageView myView = (ImageView) findViewById(R.id.dotsLoadingView);
((Animatable) myView.getDrawable()).start();
Run Code Online (Sandbox Code Playgroud)

  • `AnimationDrawable`中有一个错误,其中更改可见性始终会启动动画.直到我们开始使用`AnimationDrawable`来处理不是进度旋转器的东西,例如Material主题中的复选框和单选按钮动画,这才真正引人注目. (3认同)
  • @alanv你碰巧有关于这个的发行票的链接吗? (2认同)