android学习笔记04(LinearLayout的嵌套)

java类:

package tk.layout_04;



import android.os.Bundle; 

import android.app.Activity; 

import android.view.Menu;



public class Layout04 extends Activity {



    @Override 

    public void onCreate(Bundle savedInstanceState) { 

        super.onCreate(savedInstanceState); 

        setContentView(R.layout.layout04); 

    }



    @Override 

    public boolean onCreateOptionsMenu(Menu menu) { 

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

        return true; 

    } 

}

XML文件:

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

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

    android:orientation= "vertical" 

    android:layout_width= "fill_parent" 

    android:layout_height= "fill_parent" 

    > 

    <LinearLayout 

        android:orientation= "horizontal" 

        android:layout_width= "fill_parent" 

        android:layout_height= "fill_parent" 

        android:layout_weight="1" 

        > 

        <TextView 

            android:text="red" 

            android:gravity="center_vertical" 

            android:background="#aa0000" 

            android:layout_width="wrap_content" 

            android:layout_height="fill_parent" 

            android:layout_weight="1" 

            /> 

        <TextView 

            android:text="green" 

            android:gravity="center_vertical" 

            android:background="#00aa00" 

            android:layout_width="wrap_content" 

            android:layout_height="fill_parent" 

            android:layout_weight="1" 

            /> 

        <TextView 

            android:text="blue" 

            android:gravity="center_vertical" 

            android:background="#0000aa" 

            android:layout_width="wrap_content" 

            android:layout_height="fill_parent" 

            android:layout_weight="1" 

            /> 

                    

    </LinearLayout> 

    <LinearLayout 

        android:orientation= "vertical" 

        android:layout_width= "fill_parent" 

        android:layout_height= "fill_parent" 

        android:layout_weight="1" 

        >



        <TableLayout 

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

            android:layout_width= "fill_parent" 

            android:layout_height= "fill_parent" 

            android:stretchColumns="0" 

            > 

        

                <TableRow > 

                <TextView 

                    android:text="@string/row1_col1" 

                    android:background="#aaaa00" 

                    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>



                    

    </LinearLayout> 

    

</LinearLayout>

你可能感兴趣的:(LinearLayout)