Pan*_*ver 7 java animation android
我无法将动画应用于视图.我试图从CursorAdapter的构造函数内部加载动画,所以我可以稍后将其设置为列表中的某些子项.
在构造函数中我有:
shineAnimation = AnimationUtils.loadAnimation(ctx, R.anim.news_list_item_shine);
Run Code Online (Sandbox Code Playgroud)
动画在我的res/anim目录中
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
<item android:drawable="@drawable/shine1" android:duration="200" />
<item android:drawable="@drawable/shine2" android:duration="200" />
<item android:drawable="@drawable/shine3" android:duration="200" />
<item android:drawable="@drawable/shine4" android:duration="200" />
<item android:drawable="@drawable/shine5" android:duration="200" />
</animation-list>
Run Code Online (Sandbox Code Playgroud)
我得到一个例外:未知的动画名称:动画列表
非常感谢帮助
谢谢S.
我认为您没有AnimationDrawables通过加载AnimationUtils。AnimationDrawable是一个Drawable多于它是一个Animation。尝试SDK 指南中的示例代码。
ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
rocketImage.setBackgroundResource(R.anim.rocket_thrust);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3849 次 |
| 最近记录: |