4

我只想调整编辑文本的大小,使其与我的文本匹配。当我在第 3 列的表格布局中插入编辑文本时,它会填充第 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

您不需要指定它自己选择的列号,如果您想编辑文本以适应空间,只需将其放置在那里,只需在表格布局中拉伸第 1 列和第 2 列

或者您可以将线性布局添加为表格行并分配权重

于 2012-06-09T06:10:58.203 回答
0

尝试

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