2014-12-02 142 views
0

我正在使用tablelayout進行一項活動。在開始時佈局很好,但是當一些數據填充活動中的文件時,佈局會將其格式更改爲超出屏幕。 如何阻止佈局?android桌面佈局在屏幕外

+0

您的代碼請。 – Rami 2014-12-02 11:29:54

回答

0

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

4

你嘗試shrinkColumns選項?

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