android------布局+TableLayout

布局基础:

1、main.xml代码:

<?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">
<LinearLayout 
    	    android:layout_width="fill_parent"
    		android:layout_height="fill_parent"
   			android:orientation="horizontal"
   			android:layout_weight="1">
    	    		<TextView 
       					 android:text="red"
       					 android:gravity="center_vertical"
       					 android:layout_weight="1"
       					 android:layout_width="wrap_content"
       					 android:layout_height="fill_parent" 
       					 android:background="#aa0000"/>
    	    		<TextView 
       					  android:text="green"
       					  android:gravity="center_vertical"
       					  android:layout_weight="1"
       					 android:layout_width="wrap_content"
       					 android:layout_height="fill_parent" 
       					  android:background="#00aa00"/>
    	    		<TextView 
       					  android:text="blue"
       					  android:gravity="center_vertical"
       					  android:layout_weight="1"
       					 android:layout_width="wrap_content"
       					 android:layout_height="fill_parent" 
       					  android:background="#0000aa"/>
    	    		<TextView 
       					  android:text="black"
       					  android:gravity="center_vertical"
       					  android:layout_weight="1"
       					 android:layout_width="wrap_content"
       					 android:layout_height="fill_parent" 
       					  android:background="#000000"/>
    	</LinearLayout>

 		<TableLayout  
    	    android:layout_width="fill_parent"
    		android:layout_height="fill_parent"
    		android:orientation="vertical"
    		android:layout_weight="1"
   			android:stretchColumns="1">
    	    		<TableRow>
    	    		    		<TextView 
		       						 android:text="@string/row1_column1"
		       						 android:padding="3dip"/>
    	    		    		<TextView
		       					  	 android:text="@string/row1_column2"
		       					  	 android:gravity="center_vertical"
		       					  	 android:padding="3dip"/>	
		    	    			<TextView
		       					  	 android:text="@string/row1_column3"
		       					  	 android:gravity="right"
		       					  	 android:padding="3dip"/>	    		    
    	    		</TableRow>
    	    		<TableRow>
    	    		    		<TextView 
		       						 android:text="@string/row2_column1"
		       						 android:padding="3dip"/>
		    	    			<TextView
		    	    			    android:text="@string/row2_column2"
		       					  	android:gravity="right"
		       					  	android:padding="3dip"/>
    	    		</TableRow>	
		</TableLayout>
 </LinearLayout>

2、LinerText.java代码:

package mras.layout01;

import android.os.Bundle;
import android.app.Activity;

public class LinerText extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

3 、string.xml代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">layout01</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string>
	<string name="row1_column1">row1_column1</string>
	<string name="row1_column2">row1_column2</string>
	<string name="row1_column3">row1_column3</string>
	<string name="row2_column1">row2_column1</string>
	<string name="row2_column2">row2_column2</string>
</resources>

4、运行效果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值