【问题标题】:How to design layouts that will only rotate the outer layout not the inner layout?如何设计只会旋转外部布局而不是内部布局的布局?
【发布时间】:2019-05-08 08:15:44
【问题描述】:

我在框架布局(父)中有两个圈布局(相对)内部和外部,我需要通过两个手指手势旋转外圈,而不是内圈布局,我该如何实现这一点。Like in below picture , outer circle will only rotate with their child circle but not the inner one

【问题讨论】:

    标签: android xml android-layout android-layout-weight


    【解决方案1】:

    我相信将外部布局旋转你想要的数量,然后将内部布局旋转 360 度,这会给你想要的。

    浮动度数 = 30.0f;

    outerLayout.setRotation(度); innerLayout.setRotation(360 - 度);

    请注意,如果您需要再次旋转视图,您应该使用全角度旋转值。 3 旋转 90 度的含义,对于 4120 等。

    【讨论】:

    • 感谢 Spyros,它可以工作,但旋转速度非常快。我们可以慢慢旋转外部布局吗?
    • 您需要制作动画师并使用 android:fromDegrees 和 android:toDegrees。看看这个并尝试类似的androidhive.info/2013/06/android-working-with-xml-animations
    • 感谢 Spyros,但我已经通过手指手势检测进行旋转,顺时针和逆时针方向
    【解决方案2】:

    你可以像这样使用RelativeLayout来做到这一点

    <RelativeLayout>
    
       <LinearLayout>  //Your Outer Layout
       </LinearLayout>
    
       <LinearLayout>  //Your Inner Layout
       </LinearLayout>
    </RelativeLayout>
    

    并在您的外部布局上执行操作。您可以根据需要在 RelativeLayout 中使用任何子视图。例如,我只是使用 LinearLayout。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-06
      • 2013-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-10
      • 2013-08-27
      • 1970-01-01
      相关资源
      最近更新 更多