围绕它的中心旋转imageview

Fco*_*der 4 java android imageview android-imageview

我想创建一个模拟时钟,我有一个问题.我使用3 imageview秒,分钟和时针.现在我想让他们每个人围绕中心旋转,但我不能.如何通过给出围绕中心的角度来旋转图像视图?

kco*_*ock 6

假设您的目标是API 11,最简单的方法是:

view.setPivotX(view.getWidth() / 2);
view.setPivotY(view.getHeight() / 2);

float rotation = //some value between 0f and 360f
view.setRotation(rotation);
Run Code Online (Sandbox Code Playgroud)