【发布时间】:2021-11-17 13:26:15
【问题描述】:
我正在努力解决一个问题。我有一个充满图像的 3x3 网格。单击图像时,您可以顺时针或逆时针旋转它。然后我用.setrotation 设置旋转,但我也想为运动设置动画。
我正在使用动画师来旋转图像,但它没有设置旋转,所以我也这样做。
RotateAnimation rotate = new RotateAnimation(prevRotation, rotationClockwise, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(999);
rotate.setInterpolator(new LinearInterpolator());
rotate.setFillAfter(true);
我面临的问题是,一旦我完成动画并设置旋转,它就会再旋转 90 英尺。我相信动画师只是触发了位图,而旋转正在旋转整个视图。
我该如何解决这个问题?
【问题讨论】:
-
嗨,博兰!你也可以添加对这个方法的调用吗?您在哪里以及如何称呼它?
-
嗨乔恩,它设置为点击,我用 mImageToRotate.startAnimation(rotate); ImageView mImagetoRotate = findviewbyID(image[gridposition]);要设置我正在做的图像 mImageToRotate.setRotation(rotationClockwise)
-
看我的回答。希望有帮助!这可能比使用 RotateAnimation 类更容易——用一行来进行旋转!
标签: java android android-studio