Android TableRow 中的Textview显示不全

最近碰到了这个问题。

TabLayout 下面的 tabRow 中有2个TextView 如果输入的文本过长,会导致显示不全,这个问题真的困扰好几天了。

 

 

 

这个是 TableLayout 中没有设置 android:shrinkColumns 熟悉

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
        
         <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:shrinkColumns="1"
             >
             <TableRow
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content" >

                 <TextView
                     android:text="标题:" />

                 <TextView
                     android:text="@string/title1" />
             </TableRow>
             
              <TableRow
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content" >

                 <TextView
                     android:text="标题:" />

                 <TextView
                     android:text="@string/title2" />
             </TableRow>
             
               <TableRow
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content" >

                 <TextView
                     android:text="标题:" />

                 <TextView
                     android:text="@string/title3" />
             </TableRow>
             
                <TableRow android:background="@color/actionbar_title_color"
                >
                 <TextView
                     android:text="标题:" />

                 <TextView
                     android:text="@string/title4" />
             </TableRow>
        </TableLayout>

</LinearLayout>

 

 

 

android:shrinkColumns

The zero-based index of the columns to shrink. The column indices must be separated by a comma: 1, 2, 5. Illegal and duplicate indices are ignored. You can shrink all columns by using the value "*" instead. Note that a column can be marked stretchable and shrinkable at the same time.

Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol shrinkColumns.

Related Methods

我的理解:

android:shrinkColumns:以第0行为序,自动延伸指定的列填充可用部分:当LayoutRow里面的控件还没有布满布局时,shrinkColumns不起作用,设置了shrinkColumns=0,1,2,布局完全没有改变,因为LayoutRow里面还剩足够的空间。当LayoutRow布满控件时,设置了shrinkColumns=2,则控件自动向垂直方向填充空间

 

 

posted @ 2013-03-27 21:28  坑坑kk  阅读(3945)  评论(0编辑  收藏  举报