相对布局(上)

1. 什么是相对布局(RelativeLayout)

2. 为什么要相对布局

3. 相对布局的两组常用属性

 

1. 什么是相对布局(RelativeLayout)

   

2. 为什么要相对布局

     安卓布局中嵌套会消耗更多资源!!!

3. 相对布局的两组常用属性

    

       

       代码如下:

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     tools:context="first.pack.MainActivity$PlaceholderFragment" >
 6 
 7     <TextView
 8         android:id="@+id/firstView"   //创建id
 9         android:layout_width="wrap_content"
10         android:layout_height="wrap_content"
11         android:background="#FF0000"
12         android:text="hello_world" />
13     
14     <TextView
15         android:layout_width="wrap_content"
16         android:layout_height="wrap_content"
17         android:layout_toRightOf="@+id/firstView"   //根据id判断相对位置
18         android:background="#00FF00"
19         android:text="hello_mirror" />
20 
21 </RelativeLayout>

            

posted @ 2014-06-26 10:58  Mirrorhanman  阅读(370)  评论(0编辑  收藏  举报