我已经实现了一个 AnimationDrawable 循环通过 6 个图像帧。
这是我初始化动画的方式:
animation = new AnimationDrawable();
// images is an ArrayList<BitmapDrawable>
for (Bitmap image : images) {
BitmapDrawable drawable = new BitmapDrawable(mActivity.getResources(), image);
animation.addFrame(drawable, 200);
}
animation.setOneShot(false);
ImageView imageView = (ImageView) findViewById(R.id.backgroundImage);
imageView.setImageDrawable(animation);
// Starter implements Runnable and calls animation.start
imageView.post(new Starter());
当我运行此代码时,动画开始循环播放 6 个图像帧的列表(每个持续时间为 200 毫秒)。我看到的问题是,当它在图像中循环时,它会开始闪烁并显示其中一个帧,就像它是背景图像一样。在每一帧上。
可能有点混乱,所以我会看看我是否可以描述它......不能发布视频,因为那里有敏感信息。
假设这 6 个图像是鱼、草、狗、猫、披萨、苹果。动画应该以每帧 200 毫秒的速度循环播放这些图像。我看到的是当前显示的帧会消失,披萨帧会显示 50-100 毫秒然后消失,切换回应该显示的帧。每一帧。
我已经在 5.0 和 4.1.1 设备上进行了测试,直到现在(4.4.4)还没有看到这个问题。有人知道可能出了什么问题吗?
谢谢!
更新 我现在已经在运行 4.4.4 的三星 Galaxy S4 上进行了测试,并且没有看到这个问题。可能与摩托罗拉硬件有关?