4

テキストと一致するように編集テキストのサイズを変更したいだけです。テーブル レイアウトの列 3 に edittext を挿入すると、列 3 のスペース全体が埋まり、大きく見えます。サイズを変更したいです。それはどのように可能ですか?以下は私の.xmlコーディングです:

<TableRow>
    <TextView
        android:layout_column="1"
        android:text="S"
        android:layout_width="150dp"
        />

    <TextView
        android:layout_column="2"
        android:text="C"
        android:layout_width="75dp" />

    <TextView
        android:layout_column="3"
        android:text="G"/>
</TableRow>

<View
    android:layout_height="2dip"
    android:background="#FF909090" />

<TableRow>
<TextView
    android:layout_column="1"
    android:id="@+id/s1"
    android:text="Medium Text"/>
<TextView
    android:layout_column="2"
    android:id="@+id/c1"
    android:text="Text"/>

<EditText
    android:id="@+id/g1"
    android:layout_column="3" />
</TableRow>
4

4 に答える 4

1

私はあなたの問題を理解しています...私はwrap_contentなどを使用しようとしましたが、うまくいきませんでした。EditTextの高さを手動で設定する必要があります....コードは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="3" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:text="TextView" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="15dp"
        android:layout_weight="1" />



</TableRow>
于 2012-06-09T07:17:21.623 に答える
1

これらを試して、

1. Set the "stretchColumn" property of table layout.

2. Set the layout_width of the EditText to "wrap_content".

3. If you want you can fix the size of the EditText by manually setting 
   the layout_width value in dp or dip.
于 2012-06-09T18:28:37.557 に答える
0

試す

 <EditText 
        android:layout_width="fill_parent" 
        android:id="@+id/txthwdxml" 
        android:layout_height="wrap_content" />
于 2012-06-09T06:31:21.897 に答える
0

you don't need to specify the column number it picks it itself just place it there if you want edit text to fit the space just strech the column 1&2 in table layout

or you can add linear layout as the table row and assign weight

于 2012-06-09T06:10:58.203 に答える