[英]Android: Relative layout for Row.xml
我多次嘗試繪制相對的布局,如下圖所示。 但沒有成功。
我用油漆設計圖像以更好地解釋我的意思。 有什么建議么?
試試這個(這是我在評論中首先提出的布局):
<LinearLayout
xmlns
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="40"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
為了使其更有用(即:動態分配內容),請為這些TextView提供一些ID( android:id =“ @ + id / txtSomething” )。
很顯然,您可以使用任何其他控件來代替TextViews:按鈕,ImageViews的任意組合。
嘗試以下想法:
根-具有2個子元素的線性布局(垂直)
第一個孩子-線性布局(水平),其權重根據您的UI第二個孩子-線性布局(水平),其權重為2個孩子。
您也可以使用TableLayout ...但是它很復雜。具有2行的表布局,其中第一行有4個子項,第二行有2個子項...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.