我正在尝试通过此代码旋转孔布局:
RelativeLayout rll = (RelativeLayout) findViewById(R.id.relativeLayout1);
rll.setRotation(21);
如何设置旋转中心?我不想使用左下角作为旋转中心,因为旋转布局的某些部分不在视图中! (我不想使用动画.bcz我的按钮无法正常使用它)
答案 0 :(得分:1)
答案就在这里
Is there any way to rotate a button without using animation in android 2.1
这里
Rotate a bitmap in android about a point without animation of view
或在这里
答案 1 :(得分:0)
不确定我明白你在问什么,但试试这个:
int w = r11.getWidth();
int h = r11.getHeight();
r11.setRotation(21f);
r11.setTranslationX((w - h) / 2);
r11.setTranslationY((h - w) / 2);