ÎÒÃǾ³£Óõ½µÄ¿Ø¼þ¶¼ÊÇ View µÄÅÉÉúÀ࣬ËûÃÇͨ³£¶¼ÊǿɼûµÄ¡£ ViewGroup Ò²ÊÇ View µÄÅÉÉúÀ࣬µ« ViewGroup ͨ³£ÊDz»¿É¼ûµÄ¡£
ViewGroup µÄÖ÷Òª×÷Óãº
+ ×÷Ϊ Layout ¡£±ÈÈç LinearLayout ¡¢ RelativeLayout ¡¢ FrameLayout ºÍ TableLayout
+ ×÷Ϊ View µÄÈÝÆ÷¡£±ÈÈç Gallery ¡¢ GridView ¡¢ ImageSwitcher ¡¢ ScrollView ¡¢ TabHost ºÍ ListView
Æäʵ Layout Ò²¿ÉÒÔ±»ÈÏΪÊÇ View µÄÒ»ÖÖÈÝÆ÷¡£
±¾ÎĽöÌÖÂÛ ViewGroup ×÷Ϊ Layout µÄ³£Óü¼ÇÉ¡£
1. LinearLayout
LinearLayout ¹ËÃû˼Òå¾ÍÊÇÏßÐÔ²¼¾Ö¡£Æä×Ó View ¶ÔÏóҪôÒÔ ¡° ÐÐ ¡± ÅÅÁУ¬ÒªÃ´ÒÔ ¡° ÁÐ ¡± ÅÅÁУ¬ÕâÈ¡¾öÓÚÆä orientation ÊôÐÔÊÇ horizontal »¹ÊÇ vertical µÄ¡£
< xml version = "1.0" encoding = "utf-8" >
< LinearLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
android:orientation = "vertical"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content" >
< Button
android:id = "@+id/linearbutton01"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = " °´Å¥ 1"
/>
< Button
android:id = "@+id/linearbutton02"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = " °´Å¥ 2"
/>
< Button
android:id = "@+id/linearbutton01"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = " °´Å¥ 3"
/>
< Button
android:id = "@+id/linearbutton01"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = " °´Å¥ 4"
/>
LinearLayout >
½« Activity ¶ÔÓ¦µÄ´úÂëÖÐµÄ setContentView µÄ²ÎÊý£¬¸ÄΪ£º R.layout.linearlayout £¬ÔËÐкóµÃµ½µÄ½á¹ûÈçÏ£º
Èç¹û½« linearlayout.xml ÖÐµÄ orientation ÊôÐÔÖµ¸ÄΪ ¡±horizontal¡± £¬ÄÇôÔËÐкóµÄ½á¹ûÈçÏ£º

2. RelativeLayout
RelativeLayout ¿ÉÒÔ¸ù¾Ý×Ó View ¶ÔÏó±Ë´ËÖ®¼äµÄλÖùØÏµÀ´ÏÔʾ×Ó View ¶ÔÏó¡£±ÈÈçͨ¹ý ¡±above¡± ¡¢ ¡±below¡± ¡¢ ¡±to the left of¡± ¡¢ ¡±to the right of¡± ÆäËûµÄ×Ó View ¶ÔÏóÀ´¶¨Î»¡£
´´½¨Ò»¸ö²¼¾ÖÎļþ relativelayout.xml £¬Ê¹ÆäÄÚÈÝÈçÏ£º
< xml version = "1.0" encoding = "utf-8" >
< RelativeLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
android:id = "@+id/relativelayout"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent" >
< Button
android:id = "@+id/buttonCenter"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "Center"
android:layout_centerInParent = "true"
/>
< ImageView
android:id = "@+id/ImageView01"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_above = "@id/buttonCenter"
android:layout_centerHorizontal = "true"
android:src = "@drawable/icon"
/>
< TextView
android:id = "@+id/textview01"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_toLeftOf = "@id/buttonCenter"
android:textSize = "20px"
android:text = "Android1"
/>
< TextView
android:id = "@+id/textview02"
andro