开发者社区> 问答> 正文

Android CursorAdapter中元素上的逐帧动画问题

我在将动画应用于视图时遇到麻烦。我正在尝试从CursorAdapter的构造函数中加载动画,因此我可以进行设置,以后再将其分配给列表中的某些子级。

在构造函数中,我有:


shineAnimation = AnimationUtils.loadAnimation(ctx, R.anim.news_list_item_shine);

动画在我的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>

我遇到异常:动画名称未知:animation-list

帮助将不胜感激

谢谢S

展开
收起
Puppet 2020-01-23 13:10:38 386 0
1 条回答
写回答
取消 提交回答
  • 我认为您不会AnimationDrawables通过加载AnimationUtils。AnimationDrawable是一个Drawable多于一个的Animation。试试SDK指南中的此示例代码。

    ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image); rocketImage.setBackgroundResource(R.anim.rocket_thrust); rocketAnimation = (AnimationDrawable) rocketImage.getBackground();

    2020-01-23 13:10:50
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载