How to resize / resize an EditText in a table layout?

I just want to resize the edittext to fit my texts. When I paste the edittext into the table layout in column 3, it fills the entire space of column 3 and looks large. I want to resize. How is this possible? Following is my .xml coding:

<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
source share
4 answers

I understand your problem ... I tried using wrap_content etc. but it didn't work, you need to manually set the height of the EditText .... here is the code:

 <?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
source

Try

 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
source

you don’t need to specify the number of the column that he selects, just put it there, if you want the editing text to fit in the space, just select column 1 and 2 in the table layout

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

0
source

Try

  <EditText android:layout_width="fill_parent" android:id="@+id/txthwdxml" android:layout_height="wrap_content" /> 
0
source

All Articles