我正在努力解决一个问题。我有一个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度。我相信动画师只是触发了位图,旋转正在旋转整个视图。
我该如何着手解决这个问题呢?
发布于 2021-11-17 05:54:28
我解决这个问题的方法是使用Android中的每个View都有的animate()方法:
viewToRotate.setOnClickListener(clicked -> {
final float rotation = 90f; // Specify your rotation here
viewToRotate.animate().rotationBy(rotation).setDuration(999).start();
});
https://stackoverflow.com/questions/70005242
复制相似问题