私はAndroidアプリを開発しています。
私はこのレイアウトを持っています:
テキストビューで列全体を埋めたくありません。前の画像でわかるように、青い長方形で囲まれた 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>
8 列の TableLayout 内にあります。これが 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>
一部の textView には背景色があります。ご覧のとおり、すべてのフォームが列を埋めています。
TextView の幅を変更するにはどうすればよいですか? android:layout_span="2" を設定した場合、幅を変更できません。