-1
我對我的LinearLayout
有一定的方形空間。在此LinearLayout
我有一個RelativeLayout
與高度和寬度100dp
。這RelativeLayout
有一個圓形的可繪製的形狀。我想將RelativeLayout
的高度和寬度設置爲其母公司LinearLayout
可用總空間的60%。有沒有辦法做到這一點?如何設置相對佈局的高度和寬度百分比
佈局這是我的一個圓形視圖
<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>
如果你想在百分比來設置,你可以根據你的百分比 –
1.有使用新的約束的佈局和設置指南對於你想要達到的目標有很多答案,那麼這個60%的身高究竟是什麼意思呢? 2.您的佈局非常糟糕,可能會影響您的應用性能。 3.一旦你回覆第一點,我可以進一步幫助#1和# –
你能否建議我最好的方式來表示這種佈局 –