TextView中gravity属性值测定

Attributes Explain
top 不改变控件大小,对齐到容器顶部
bottom 不改变控件大小,对齐到容器底部
left 不改变控件大小,对齐到容器左侧
right 不改变控件大小,对齐到容器右侧
center_vertical 不改变控件大小,对齐到容器纵向中央位置
center_horizontal 不改变控件大小,对齐到容器横向中央位置
center 不改变控件大小,对齐到容器中央位置
fill_vertical 若有可能,纵向拉伸以填满容器
fill_horizontal 若有可能,横向拉伸以填满容器
fill 若有可能,纵向横向拉伸以填满容器

在TableLayout布局中,出现了以下警告:

This TableRow layout or its TableLayout parent is useless

解决办法很简单,比如你原来的代码可能是:

 
  1. <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:layout_width="fill_parent"  
  3.     android:layout_height="fill_parent" >  
  4.        
  5.     <TableRow>  
  6.          <TextView/>  
  7.          <TextView/>  
  8.     </TableRow>  
  9.        
  10.   
  11. </TableLayout>  

你只需改为下面的即可:

  1. <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:layout_width="fill_parent"  
  3.     android:layout_height="fill_parent" >  
  4.        
  5.     <TableRow>  
  6.          <TextView/>  
  7.          <TextView/>  
  8.     </TableRow>  
  9.     <TableRow>  
  10.          <TextView/>  
  11.          <TextView/>  
  12.     </TableRow>  
  13.   
  14. </TableLayout>  

posted @ 2013-08-07 19:41  KillerLegend  Views(2172)  Comments(0Edit  收藏  举报