在animationdrawable的帧之间设置动画

时间:2015-12-04 13:40:54

标签: android animation bitmap

我有一个ImageView和两个图像到位图,这些图像暂时设置为imageview:

    AnimationDrawable staticAnimation = new AnimationDrawable();
    staticAnimation.addFrame(new BitmapDrawable(context.getResources(), bmp[0]),150);
    staticAnimation.addFrame(new BitmapDrawable(context.getResources(), bmp[1]),150);
    staticAnimation.addFrame(new BitmapDrawable(context.getResources(), bmp[2]),150);
    iv.setImageDrawable(staticAnimation);
    staticAnimation.start();

问题:

如何在更改位图时添加动画?例如,第一张图像淡出,第二张图像平滑淡入。

  • 我无法使用ImageSwitcherPageViewer
  • 此应用在一个视图(当前为imageview)
  • 中执行所有动画非常重要

感谢任何提示,帮助,......

1 个答案:

答案 0 :(得分:1)

使用TransitionDrawable在ImageView中更改位图时添加动画,如下所示: -

Drawbale[] drawables = new Drawable[x];
TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);
imageView.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(5000);