我有TableRow。在表格行內我有一些textview。如何設置TableRow中Table列的背景色
對於我的要求,Textview高度應該是wrap_content。
如果我給背景顏色它將被設置爲Textview。它不會填滿整行。
就像下面的圖片
但我需要的是背景應設置爲整列而不是TextView的。
這裏我添加了我的代碼。
<TableRow
android:id="@+id/tableRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:gravity="center"
android:minHeight="?attr/actionBarSize">
<TextView
android:id="@+id/subject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="198"
android:background="@color/colorAccent"
android:gravity="center"
android:text="Subject"
android:textColor="@color/colorWhite"
android:textStyle="bold"></TextView>
<TextView
android:id="@+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="98"
android:background="@color/colorSecondary"
android:gravity="center"
android:text="Date"
android:textColor="@color/colorWhite"
android:textStyle="bold"></TextView>
<TextView
android:id="@+id/Time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="98"
android:background="@color/colorPrimaryDark"
android:gravity="center"
android:text="Time"
android:textColor="@color/colorWhite"
android:textStyle="bold"></TextView>
</TableRow>
在ID tableRow中設置背景顏色而不是主題。用/>替換>。它使更整潔的代碼。 – apmartin1991