【问题标题】:android Tablelayout out of screenandroid Tablelayout屏幕外
【发布时间】:2015-04-25 09:00:35
【问题描述】:

我正在使用表格布局进行活动。在开始时布局很好,但是当一些数据填充活动上的文件时,布局会改变其形式到屏幕之外。 如何阻止布局?

【问题讨论】:

    标签: android tablelayout


    【解决方案1】:

    您尝试过shrinkColumns 选项吗?

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2021-08-30
        • 2011-01-24
        • 1970-01-01
        • 2012-05-11
        • 1970-01-01
        • 2012-07-23
        • 2011-12-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多