Android学习历程-LinearLayout布局
<?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:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <TextView android:text="red" android:background="#aa0000" android:layout_width="0dip" android:layout_height="fill_parent" android:gravity="center_horizontal" android:layout_weight="1"/> <TextView android:text="green" android:background="#00aa00" android:layout_width="0dip" android:layout_height="fill_parent" android:gravity="center_horizontal" android:layout_weight="1"/> <TextView android:text="blue" android:background="#0000aa" android:layout_width="0dip" android:layout_height="fill_parent" android:gravity="center_horizontal" android:layout_weight="1"/> <TextView android:text="yellow" android:background="#aaaa00" android:layout_width="0dip" android:layout_height="fill_parent" android:gravity="center_horizontal" android:layout_weight="1"/> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <TextView android:text="row one" android:textSize="15pt" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1"/> <TextView android:text="row two" android:textSize="15pt" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1"/> <TextView android:text="row three" android:textSize="15pt" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1"/> <TextView android:text="row four" android:textSize="15pt" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1"/> </LinearLayout> </LinearLayout>
package com.example.testcontextmenu; import android.app.Activity; import android.os.Bundle; public class TestLinearLayout extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test_linear_layout); } }