android > layout > TableLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
     >
	   
	<TableLayout 
		android:layout_width="fill_parent"	    
		android:layout_height="wrap_content"
		android:background="#ff0000"
		android:stretchColumns="*"		//拉伸某列单元格,从0开始, * 表示拉伸所有
	    >
	    <TableRow>  
	        <TextView   
	            android:text="column1"
	            android:background="#00ff00"   
	            android:layout_margin="1dip"  />   
	        <TextView   
	            android:text="column2"  
	            android:background="#00ff00"    
	            android:layout_margin="1dip"  />   
	  
	        <TextView   
	            android:text="column3" 
	            android:background="#00ff00"   
	            android:layout_margin="1dip"  />   
	    </TableRow>  	    
		<View
        android:layout_height="2dip" 
        android:background="#F00" />   
	    <TableRow>  
	        <TextView   
	            android:text="column1"   
	            android:background="#00ff00"  
	            android:layout_margin="1dip"  />   
	        <TextView   
	            android:text="column2"   
	            android:gravity="center"
	            android:layout_span="2"			//合并2个单元格
				android:background="#00ff00"  
	            android:layout_margin="1dip"  />   
	    
	    </TableRow> 	    	    
	</TableLayout>
   
</LinearLayout>
 


猜你喜欢

转载自mft.iteye.com/blog/1767492