旋转布局而不使用动画



我正在尝试通过以下代码旋转孔布局:

RelativeLayout rll = (RelativeLayout) findViewById(R.id.relativeLayout1);
rll.setRotation(21);

如何设置旋转中心?我不想使用左下角作为旋转中心,因为旋转布局的一些部分是在视图之外!!(我不想用动画。BCZ我的按钮不能正常工作)

答案在这里

是否有任何方法旋转按钮而不使用动画在android 2.1

这里

在没有动画的情况下,在android中围绕点旋转位图

这里

Android中的旋转视图

我不确定我明白你在问什么,但试试这个:

 int w = r11.getWidth();
 int h = r11.getHeight();
 r11.setRotation(21f);
 r11.setTranslationX((w - h) / 2);
 r11.setTranslationY((h - w) / 2);

最新更新