Android 实现动画书样式动画的更好方法?
我使用Android 实现动画书样式动画的更好方法?,android,Android,我使用处理程序以延迟的时间间隔简单地发布,循环遍历一组可绘制资源,并相应地设置imageResource。它工作得很好,但“动画”不是超级平滑的。有没有其他方法来实现这种类型的动画,我只是像动画书一样翻转图像 请看以下内容: 我认为这个页面卷曲效果很棒。你想要的是Android中的“帧动画”。图像和在屏幕上显示的时间在XML文件中定义。有关详细信息,请参阅下面的链接: 下面是我如何让它在我编写的快速测试应用程序中运行的: setContentView(R.layout.main);
处理程序
以延迟的时间间隔简单地发布,循环遍历一组可绘制资源,并相应地设置imageResource
。它工作得很好,但“动画”不是超级平滑的。有没有其他方法来实现这种类型的动画,我只是像动画书一样翻转图像 请看以下内容:
我认为这个页面卷曲效果很棒。你想要的是Android中的“帧动画”。图像和在屏幕上显示的时间在XML文件中定义。有关详细信息,请参阅下面的链接:
下面是我如何让它在我编写的快速测试应用程序中运行的:
setContentView(R.layout.main);
ImageView rocketImage = (ImageView) findViewById(R.id.imageView1);
rocketImage.setBackgroundResource(R.drawable.jena);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
然后,在我的drawable文件夹中有jena.xml:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/jenaveve0000" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0001" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0002" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0003" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0004" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0005" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0006" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0007" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0008" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0031" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0032" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0033" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0034" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0035" android:duration="500"/>
<item android:drawable="@drawable/jenaveve0036" android:duration="500"/>
</animation-list>
谢谢你,奥特曼。“动画书”可能是一个误导性的术语。我不需要页面翻转效果。我只是一个接一个地设置图像,以产生移动动画的效果。每个图像只是略有不同。。。你知道我的意思。我只是想知道是否有一些优化或不同的方法来让这更平滑。我明白你的意思。位图或可绘制缓存可以帮助您吗?就像WeakHashMap mCache=new WeakHashMap();启动一个后台线程来维护缓存并从缓存中加载图像。这是肯定的,尽管由于某些原因它拒绝工作。我已经通过编程完成了,比如animationDrawable.addFrame。。。然后调用start(),但它只显示第一帧。我可以使用我的处理器。(AnimationDrawable本身可能只是使用了一个处理程序本身,尽管我没有仔细查看@source)
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasFocus);
rocketAnimation.start();