我有一个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();
问题:
如何在更改位图时添加动画?例如,第一张图像淡出,第二张图像平滑淡入。
ImageSwitcher
或PageViewer
感谢任何提示,帮助,......
答案 0 :(得分:1)
使用TransitionDrawable在ImageView中更改位图时添加动画,如下所示: -
Drawbale[] drawables = new Drawable[x];
TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);
imageView.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(5000);