2

私はテーブルレイアウトを使用しています。2 つの列があります。最初の列にはテキスト ビューが含まれ、もう 1 つは EditText です。私のレイアウトは次のようになります。

column1: columnvalue1
column2: columnvalue2
col3: columnvalue3

しかし、私のレイアウトは次のように自動調整されます:

column1: columnvalue1
column2: columnvalue2
col3:    columnvalue3

最初のもののようなレイアウトを解決する方法。それの間違いは何ですか?何か考えはありますか?

コード: 単一行のコードを書き留めました。参考のため。このコードのように、すべての行に対して行いました。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content" android:layout_height="fill_parent"
            android:stretchColumns="1" android:background="@drawable/corner_white"
            android:layout_margin="10dip">
<TableRow android:orientation="horizontal"
                android:minHeight="50dip" android:gravity="center_vertical">
                <TextView android:text="@string/ename" android:textSize="15sp"
                    android:textColor="@color/black" android:padding="10dip" />
                <EditText android:id="@+id/ename_value" android:textSize="15sp"
                    android:inputType="textEmailAddress" android:background="@null"
                    android:singleLine="true" />
            </TableRow>
        </TableLayout>
4

1 に答える 1

3

間違いはありません。まさにそれが TableLayout の目的です。列の幅を同じにしたくない場合は、テーブルから 3 番目の行を取り出して、それを独自の水平方向の LinearLayout に配置します。

(ちなみに、例では列と行を混同しています。次のように言う必要があります。

row1: row1 value
row2: row2 value
r3: row3 value
于 2010-06-03T13:54:44.153 に答える