我需要建立類似於以下佈局:的Android的TextView FILL_PARENT
的三排左邊是TextViews,其總高度爲開頭未知。右側的元素應該是任何可以動態更改其背景色的控件。它應該跨越其高度來填補父母。
我該如何做到這一點?我應該使用什麼小部件來顯示顏色?什麼佈局?
我嘗試使用正確的元素TextView以下,但它不會填充父項。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/txtRow_color"
android:layout_width="10dip"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:background="#ff23cf"
android:text="" />
<TextView
android:id="@+id/txtRow_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/txtRow_color"
android:textColor="#FFFF66"
android:text="@string/nullstring" />
<TextView
android:id="@+id/txtRow_Tweet"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_below="@id/txtRow_name"
android:layout_toLeftOf="@id/txtRow_color"
android:layout_alignWithParentIfMissing="true"
android:gravity="center_vertical"
android:text="@string/nullstring" />
</RelativeLayout>
它做到了! LinearLayout是解決方案。謝謝! – thameera