android布局与源码
横向线性布局加relativeLayout
public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);LinearLayout layoutMain = new LinearLayout(this);layoutMain.setOrientation(LinearLayout.HORIZONTAL);setContentView(layoutMain);LayoutInflater inflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);//xml加载器RelativeLayout layoutLeft = (RelativeLayout) inflate.inflate(R.layout.left, null);RelativeLayout layoutRight = (RelativeLayout) inflate.inflate(R.layout.right, null);RelativeLayout.LayoutParams relParam = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);layoutMain.addView(layoutLeft, 100, 100);//先加入第一个相对布局的xml,并规定宽度和高度layoutMain.addView(layoutRight, relParam);//剩下的空间由这个相对布局xml填充}
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="上" /><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="左下" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="右下" /> </LinearLayout>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="表头"/><TableRowandroid:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="第0列" --android:layout_marginLeft="10dip"></TextView><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="第1列"></TextView></TableRow><TableRowandroid:gravity="center"><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮1"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮2"/></TableRow></TableLayout>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="中间的按钮,很长很长很长" android:layout_centerInParent="true" > </Button> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="上面的按钮" android:layout_above="@id/button1" android:layout_alignLeft="@id/button1" > </Button> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="下面的按钮" android:layout_below="@id/button1" android:layout_alignRight="@id/button1" --android:layout_alignParentRight="true" 这个也常用 > </Button> </RelativeLayout>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/big" > </ImageView> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/center" > </ImageView> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/small" > </ImageView> </FrameLayout>