2016-10-22 255 views
-1

我对我的LinearLayout有一定的方形空间。在此LinearLayout我有一个RelativeLayout与高度和宽度100dp。这RelativeLayout有一个圆形的可绘制的形状。我想将RelativeLayout的高度和宽度设置为其母公司LinearLayout可用总空间的60%。有没有办法做到这一点?如何设置相对布局的高度和宽度百分比

这是我设计 enter image description here

布局这是我的一个圆形视图

<RelativeLayout 
      android:id="@+id/rl_hatchback" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 

      > 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_centerInParent="true" 
       android:orientation="vertical"> 

      <RelativeLayout 
       android:id="@+id/rl_hatchback_circle" 
       android:layout_width="100dp" 
       android:layout_height="100dp" 
       android:background="@drawable/circle_red" 

       > 
       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_hatchback" 
        android:layout_centerInParent="true" 
        /> 
      </RelativeLayout> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/rl_hatchback_circle" 
        android:text="Hatchback" 
        style="@style/CircularTitle" 
        /> 
      </LinearLayout> 
+0

如果你想在百分比来设置,你可以根据你的百分比 –

+0

1.有使用新的约束的布局和设置指南对于你想要达到的目标有很多答案,那么这个60%的身高究竟是什么意思呢? 2.您的布局非常糟糕,可能会影响您的应用性能。 3.一旦你回复第一点,我可以进一步帮助#1和# –

+0

你能否建议我最好的方式来表示这种布局 –

回答

相关问题