Salut!我在relativelayout中遇到問題,其子代可以使用layout_below和layout_weight設置其百分比高度。RelativeLayout和height百分比。無法使用layout_below和layout_weight
例如。我們有相對的佈局,裏面有3個帶textviews的線性佈局。現在,我想爲它們中的3個(線性佈局)設置相對佈局總高度的25,50.25%。我怎麼能做到這一點?
我找到了weight_sum and and relativelayout (CLICK)的解決方案,但它沒有使用layout_below。
請幫忙。我試圖在所有線性佈局中添加額外的線性佈局,但之後我無法使用layout_below。
這裏是概念PIC的想法:
這裏是我的代碼:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/linlay_leftcol_notification_header" >
<LinearLayout
android:id="@+id/linlay_leftcol_clock_theday"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tv_theday"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/theday"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="@+id/linlay_leftcol_clock_thetime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linlay_leftcol_clock_theday" >
<TextView
android:id="@+id/tv_thetime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/thetime"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="@+id/linlay_leftcol_clock_thenumber_themonth_theyear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linlay_leftcol_clock_thetime" >
<TextView
android:id="@+id/tv_thenumberofday_themonth_theyear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/thenumberofday_themonth_theyear"
android:textColor="#FFFFFF" />
</LinearLayout>
</RelativeLayout>
附:請原諒語法,因爲我仍然在學習這種語言。我已經在發佈之前尋找解決方案。
-1,因爲我說的話有關百分比高度 – deadfish
如果你看看內3個佈局的緊密我一直保持權重1,2和1(按順序)保持期望的輸出,即第一個佈局將佔據顯示高度的25%,第二個將佔用50%,第三個將保留25%。對我來說工作得很好。 – Gagan
試用後,如果您對此答案感到滿意,那麼可能是您想要撤銷您的'-1':-) – Gagan