简体   繁体   中英

android Tablelayout out of screen

I'm using tablelayout for an activity. At the start time the layout is fine but when some data populate the fileds on the activity the layout changes its form going outside of the screen. How can I block the layout?

Did you try shrinkColumns option?

<TableLayout
android:shrinkColumns="*"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
...

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_column="1"> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="0"> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"> </TableRow> <TableRow> <TextView android:layout_width="fill_parent" android:gravity="left" android:text="@string/loc_label" /> <EditText android:id="@+id/editText" android:layout_width="fill_parent" android:layout_column="2" android:gravity="right" /> </TableRow> <TableRow> <TextView android:layout_width="fill_parent" android:padding="3dip" android:text="@string/precipMM" /> <TextView android:id="@+id/precipMM_value_tv" android:layout_width="fill_parent" android:layout_column="2" android:gravity="right" android:padding="3dip" android:text="@string/nodata" /> </TableRow> <TableRow> <TextView android:layout_width="fill_parent" android:padding="3dip" android:text="@string/descrWeather" /> <TextView android:id="@+id/descrTV" android:layout_width="fill_parent" android:layout_column="2" android:gravity="right" android:padding="3dip" android:text="@string/nodata" /> </TableRow> <TableRow> <Button android:id="@+id/buttonConnect" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="0" android:text="@string/updateButton" /> <Button android:id="@+id/closeButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_column="2" android:text="@string/closeButton" /> </TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"></TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"></TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"></TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"></TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"></TableRow> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"> </TableRow> </TableLayout> </RelativeLayout> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM