android学习笔记02(TableLayout)

java类:

package tk.layout_02;



import android.os.Bundle; 

import android.app.Activity; 

import android.view.Menu;



public class MyLayout02 extends Activity {



    @Override 

    public void onCreate(Bundle savedInstanceState) { 

        super.onCreate(savedInstanceState); 

        setContentView(R.layout.layout02); 

    }



    @Override 

    public boolean onCreateOptionsMenu(Menu menu) { 

        getMenuInflater().inflate(R.menu.layout02, menu); 

        return true; 

    } 

}

 

XML文件:

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

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width= "fill_parent" 

    android:layout_height= "fill_parent" 

    android:stretchColumns="2" 

    >



        <TableRow > 

        <TextView 

            android:text="@string/row1_col1" 

            android:background="#aa0000" 

            android:padding="3dip" 

            /> 

         <TextView 

            android:text="@string/row1_col2" 

            android:background="#00aa00" 

            android:gravity="right" 

            android:padding="3dip" 

            /> 

         <TextView 

            android:text="@string/row1_col3" 

            android:background="#0000aa" 

            android:gravity="right" 

            android:padding="3dip" 

            /> 

         



     </TableRow> 

       <TableRow >     

        <TextView 

            android:text="@string/row2_col1" 

            android:padding="3dip" 

            /> 

         <TextView 

            android:text="@string/row2_col2" 

            android:gravity="right" 

            android:padding="3dip" 

            /> 

        



     </TableRow> 

    



</TableLayout>

你可能感兴趣的:(tablelayout)