TableRow를 사용하고 있습니다. 테이블 행 내에서 일부 textview가 있습니다.TableRow 안에 Table 열의 배경색을 설정하는 방법
내 요구 사항에 따라 텍스트 뷰 높이가 wrap_content 여야합니다.
배경색을 지정하면 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