安卓旋转动画

标签 android android-animation

我有一个问题,但我无法设法找到有效的解决方案。 所以,这是我的问题。我必须制作一个 ImageView 来旋转自身,在方向改变时旋转 90 度。 我这样做了,图像实际上旋转得非常棒,但是当动画结束时,图像会自行重置到之前的位置。

这是我用来旋转图像的代码:

   Matrix matrix = mImageView.getImageMatrix();
                    RectF dst = new RectF();
                    matrix.mapRect(dst, new RectF(mImageView.getDrawable().getBounds()));
                    mAnimation = new RotateAnimation(0.0f, -90.0f, Animation.RELATIVE_TO_SELF, 0.5f,
                            Animation.RELATIVE_TO_SELF, 0.5f);
                    mAnimation.setDuration(5000);
                    mImageView.startAnimation(mAnimation);
                    mImageView.setImageMatrix(matrix);
                    mCurrentOrientation = 1;

最佳答案

您可以使用它在动画完成后持续存在:

mAnimation.setFillEnabled(true);
mAnimation.setFillAfter(true);

关于安卓旋转动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16484510/

相关文章:

android - android中 float Action 按钮的简单动画?

android - Honeycomb android :hardwareAccelerated ="true" manifest setting apply for Live Wallpapers?是否

java - Android 推荐跟踪不适用于 Google Play

android - AnimationDrawable 不适用于 2.3.6 android 版本

android - 动画开始时的动画菜单项 "jumps"

android - 在上滑面板中旋转 ImageView

android - Ellipsize - 开始在 TextView 中不起作用

android - 在 BuildConfig.DEBUG 时删除 ActionbarSherlock 日志

android - Android 中的 fbShare

安卓倒车动画