1
我想構建一個匹配其父寬度的視圖(理想情況下是LinearLayout)。這個佈局應該有2個孩子(水平方向):如何創建固定/動態寬度列布局?
- 一個TextView應該佔據所有可用寬度 - 或者至少包含其內容(但不包括其他視圖重疊)。
- 其他具有固定寬度60dp的LinearLayout。
這裏是我想要達到一個基本的素描:
我想構建一個匹配其父寬度的視圖(理想情況下是LinearLayout)。這個佈局應該有2個孩子(水平方向):如何創建固定/動態寬度列布局?
這裏是我想要達到一個基本的素描:
我最近回答了這個here。只是交換在回答第二個TextView的與您的孩子的LinearLayout
如何:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:background="#ff0000"
android:gravity="center"
android:text="TextView Multiline"
android:textSize="10dp"
android:textColor="#ffffff"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="60dp"
android:layout_height="fill_parent"
android:gravity="center"
android:background="#0000ff" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="#ffffff"
android:textSize="10dp"/>
</LinearLayout>
</LinearLayout>
雖然60 DP真的是窄恕我直言