【问题标题】:rotate a layout without using animation不使用动画旋转布局
【发布时间】:2014-08-14 06:04:10
【问题描述】:

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

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

如何设置旋转中心?我不想使用左下角作为旋转中心,因为旋转布局的某些部分不在视图中! (我不想使用动画。bcz 我的按钮无法正常使用它)

【问题讨论】:

    标签: android android-layout rotation


    【解决方案1】:
    【解决方案2】:

    不确定我是否理解您的要求,但试试这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-17
      • 2013-11-23
      • 1970-01-01
      • 2017-08-06
      • 2013-04-06
      • 2015-05-25
      • 1970-01-01
      • 2015-10-01
      相关资源
      最近更新 更多