如果看了我上面的兩個Layout布局的代碼的話對這個肯定感覺不到什麼難度,那我就先把結果圖貼出來,我是先看了成果自己寫的,嵌套中有三個LinearLayout。這個有點像Div+Css...不大複雜。貼圖咯。
如果大家已經把上面的寫出來就不要看下面的代碼了。這一節只是一個總結,下一節比較精彩。
main.xml
<?xml version="1.0" encoding="utf-8"?><br /><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br /> android:orientation = "vertical"<br /> android:layout_width = "fill_parent"<br /> android:layout_height = "fill_parent"<br /> ></p><p> <LinearLayout<br /> android:orientation = "horizontal"<br /> android:layout_width = "fill_parent"<br /> android:layout_height = "fill_parent"<br /> android:layout_weight = "1"></p><p> <TextView<br /> android:text = "red"<br /> android:gravity = "center_horizontal"<br /> android:background = "#aa0000"<br /> android:layout_width = "wrap_content"<br /> android:layout_height = "fill_parent"<br /> android:layout_weight = "1"/><br /> <TextView<br /> android:text = "green"<br /> android:gravity = "center_horizontal"<br /> android:background = "#00aa00"<br /> android:layout_width = "wrap_content"<br /> android:layout_height = "fill_parent"<br /> android:layout_weight = "1"/><br /> <TextView<br /> android:text = "blue"<br /> android:gravity = "center_horizontal"<br /> android:background = "#0000aa"<br /> android:layout_width = "wrap_content"<br /> android:layout_height = "fill_parent"<br /> android:layout_weight = "1"/><br /> <TextView<br /> android:text = "yellow"<br /> android:gravity = "center_horizontal"<br /> android:background = "#aaaa00"<br /> android:layout_width = "wrap_content"<br /> android:layout_height = "fill_parent"<br /> android:layout_weight = "1"/><br /> </LinearLayout></p><p> <LinearLayout<br /> android:orientation = "vertical"<br /> android:layout_width = "fill_parent"<br /> android:layout_height = "fill_parent"<br /> android:layout_weight = "1"></p><p> <TextView<br /> android:text = "row one"<br /> android:textSize = "15pt"<br /> android:layout_width = "fill_parent"<br /> android:layout_height = "wrap_content"<br /> android:layout_weight = "1"/><br /> <TextView<br /> android:text = "row two"<br /> android:textSize = "15pt"<br /> android:layout_width = "fill_parent"<br /> android:layout_height = "wrap_content"<br /> android:layout_weight = "1"/><br /> <TextView<br /> android:text = "row three"<br /> android:textSize = "15pt"<br /> android:layout_width = "fill_parent"<br /> android:layout_height = "wrap_content"<br /> android:layout_weight = "1"/><br /> <TextView<br /> android:text = "row four"<br /> android:textSize = "15pt"<br /> android:layout_width = "fill_parent"<br /> android:layout_height = "wrap_content"<br /> android:layout_weight = "1"/><br /> </LinearLayout></p><p></LinearLayout><br />