2
저는 Android 앱을 개발 중입니다. 나는 텍스트 뷰는 전체 열을 채울 수 있도록 싶지 않아전체 열을 채우는 TextView 허용 안 함
:
나는이 레이아웃을 가지고있다. 이전 이미지에서 볼 수 있듯이 파란색 직사각형으로 둘러싸인 TextView가 있습니다 (실제로 선택되어 있음). TableRow를 생성하는 XML 코드는 다음과 같습니다.
<TableRow>
<TextView
android:id="@+id/txtFactLoc"
android:layout_span="2"
android:gravity="center_vertical|right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/layout_fac_location"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/factLocVal"
android:layout_span="4"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:layout_height="match_parent"
android:background="@color/textview_background"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtConFactLoc"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/layout_confirm"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/rGroupFactLoc"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/rFactLocYes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/layout_yes" />
<RadioButton
android:id="@+id/rFactLocNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/layout_no" />
</RadioGroup>
</TableRow>
TableLayout 안에는 8 개의 열이 있습니다. 이것은 TableLayout의 시작입니다.
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow>
<TextView
android:id="@+id/txtPONo"
android:layout_weight=".125"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="@string/layout_po_no"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/pONoVal"
android:layout_weight=".125"
android:layout_width="0dip"
android:paddingLeft="10dp"
android:layout_height="match_parent"
android:background="@color/textview_background"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtIndNo"
android:layout_weight=".125"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="@string/layout_ind_no"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/indNoVal"
android:layout_weight=".125"
android:layout_width="0dip"
android:paddingLeft="10dp"
android:layout_height="match_parent"
android:background="@color/textview_background"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtTimeIn"
android:layout_weight=".1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="@string/layout_time_in"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/timeInVal"
android:layout_weight=".15"
android:layout_width="0dip"
android:paddingLeft="10dp"
android:layout_height="match_parent"
android:background="@color/textview_background"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/txtTimeOut"
android:layout_weight=".1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="@string/layout_time_out"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/timeOutVal"
android:layout_weight=".15"
android:layout_width="0dip"
android:paddingLeft="10dp"
android:layout_height="match_parent"
android:background="@color/textview_background"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
일부 textViews는 배경색을 가지고 있습니다. 당신이 볼 수 있듯이이 모든 것들이 그 칸을 채우고 나는이 모양이 매우 못생긴 것처럼 보이기를 원하지 않습니다.
어떻게 TextView 너비를 변경할 수 있습니까? android : layout_span = "2"로 설정하면 폭을 변경할 수 없습니다.
감사하지만 답변을 이해할 수 없습니다. 나는'android : stretchColumns = "*"'를 내 TableLayout 태그에 넣었다. – VansFannel