Android开发之路——Android的布局初步3——多个Layout嵌套布局


如果看了我上面的两个Layout布局(见Android开发之路——Android的布局初步 与 Android开发之路——Android的布局初步2——TableLayout布局)的代码的话对这个肯定感觉不到什么难度,那我就先把结果图贴出来,我是先看了成果自己写的,嵌套中有三个LinearLayout。这个有点像Div+Css...不大复杂。贴图咯。

相关阅读:

Android开发之路——走进Android(工程结构剖析)
Android开发之路——第一个Android小程序(Android电话拨号器)
Android开发之路——第二个Android小程序(Android短信发送)
Android开发之路——第三个Android小程序(Android的Activity显示)
Android开发之路——Android的布局初步
Android开发之路——Android的布局初步2——TableLayout布局
Android开发之路——Android的布局初步3——多个Layout嵌套布局
Android开发之路——单选框,复选框,弹出框等控件操作
Android开发学习笔记补充记录——Activity的生命周期

如果大家已经把上面的写出来就不要看下面的代码了。这一节只是一个总结,下一节(见)比较精彩。

main.xml

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.    android:orientation = "vertical"  
  4.    android:layout_width = "fill_parent"  
  5.    android:layout_height = "fill_parent"  
  6.    >  
  7.      
  8.    <LinearLayout  
  9.         android:orientation = "horizontal"  
  10.         android:layout_width = "fill_parent"  
  11.         android:layout_height = "fill_parent"  
  12.         android:layout_weight = "1">  
  13.       
  14.         <TextView  
  15.             android:text = "red"  
  16.             android:gravity = "center_horizontal"  
  17.             android:background = "#aa0000"  
  18.             android:layout_width = "wrap_content"  
  19.             android:layout_height = "fill_parent"  
  20.             android:layout_weight = "1"/>  
  21.         <TextView  
  22.             android:text = "green"  
  23.             android:gravity = "center_horizontal"  
  24.             android:background = "#00aa00"  
  25.             android:layout_width = "wrap_content"  
  26.             android:layout_height = "fill_parent"  
  27.             android:layout_weight = "1"/>  
  28.         <TextView  
  29.             android:text = "blue"  
  30.             android:gravity = "center_horizontal"  
  31.             android:background = "#0000aa"  
  32.             android:layout_width = "wrap_content"  
  33.             android:layout_height = "fill_parent"  
  34.             android:layout_weight = "1"/>  
  35.         <TextView  
  36.             android:text = "yellow"  
  37.             android:gravity = "center_horizontal"  
  38.             android:background = "#aaaa00"  
  39.             android:layout_width = "wrap_content"  
  40.             android:layout_height = "fill_parent"  
  41.             android:layout_weight = "1"/>  
  42.     </LinearLayout>  
  43.       
  44.     <LinearLayout  
  45.         android:orientation = "vertical"  
  46.         android:layout_width = "fill_parent"  
  47.         android:layout_height = "fill_parent"  
  48.         android:layout_weight = "1">  
  49.           
  50.         <TextView  
  51.             android:text = "row one"  
  52.             android:textSize = "15pt"  
  53.             android:layout_width = "fill_parent"  
  54.             android:layout_height = "wrap_content"  
  55.             android:layout_weight = "1"/>  
  56.         <TextView  
  57.             android:text = "row two"  
  58.             android:textSize = "15pt"  
  59.             android:layout_width = "fill_parent"  
  60.             android:layout_height = "wrap_content"  
  61.             android:layout_weight = "1"/>  
  62.         <TextView  
  63.             android:text = "row three"  
  64.             android:textSize = "15pt"  
  65.             android:layout_width = "fill_parent"  
  66.             android:layout_height = "wrap_content"  
  67.             android:layout_weight = "1"/>  
  68.         <TextView  
  69.             android:text = "row four"  
  70.             android:textSize = "15pt"  
  71.             android:layout_width = "fill_parent"  
  72.             android:layout_height = "wrap_content"  
  73.             android:layout_weight = "1"/>  
  74.     </LinearLayout>  
  75.           
  76. </LinearLayout>  

相关内容