[英]How to change/resize EditText in table layout?
我只想調整edittext的大小,使其與我的文本匹配。 當我在第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>
我了解您的問題...我嘗試使用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>
試試這些
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.
您無需指定列號即可自行選擇,只需要將其放置在此處即可,如果您想編輯文本以適合空間,只需在表格布局中拉伸第1和2列即可
或者您可以將線性布局添加為表格行並分配權重
嘗試
<EditText
android:layout_width="fill_parent"
android:id="@+id/txthwdxml"
android:layout_height="wrap_content" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.