我需要一个简单的动画,显示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();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。