gpt4 book ai didi

安卓旋转动画

转载 作者:行者123 更新时间:2023-11-30 03:37:14 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com