我有一个问题,但我无法设法找到有效的解决方案。
所以,这是我的问题。我必须制作一个 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/