哪个是显示具有多个帧的动画视图的最佳策略?

时间:2014-07-06 09:06:50

标签: android animation view

我想在屏幕上显示一个开口和闭合的视图。

嘴巴将有3帧(3个图像状态),打开,关闭和半开。

我希望每个帧等待300毫秒,直到显示下一帧。

执行此操作的最佳策略是什么?

1 个答案:

答案 0 :(得分:2)

使用AnimationDrawable

<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/image1" android:duration="300" />
    <item android:drawable="@drawable/image2" android:duration="300" />
    <item android:drawable="@drawable/image3" android:duration="300" />
</animation-list>

然后:

    view.setBackgroundResource(R.drawable.animation_list_resource_name);
    AnimationDrawable animation = (AnimationDrawable) view.getBackground();
    animation.start();