我是靠谱客的博主 凶狠滑板,这篇文章主要介绍Android移动开发--相对布局,现在分享给大家,希望可以做个参考。

1.第一组属性:android:layout_below,layout_above,layout_toLeftOf,layout_toRightOf

第二组属性:android:layout_alignLeft,right,top,bottom(对齐)

2.对齐至控件的基准线

android:layout_alignBaseline

144828_BLld_2861931.png

145009_6yXJ_2861931.png

 

3.与父控件的四个边缘对齐,对齐父控件中央

android:layout_alignParentLeft,right,top,bottom(对齐)

145306_OaoW_2861931.png

android:layout_centerInParent,Horizontal,Vertical

145408_Prww_2861931.png145449_plqC_2861931.png145428_Uh6z_2861931.png

4.android4.2新属性

android:layout_alignStart,End,ParentStart,End

145809_ygRq_2861931.png145749_9h0J_2861931.png

5.例子:登录界面

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:padding="40dp" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/editText" android:hint="username" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_below="@+id/textView" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/editText2" android:hint="password" android:layout_alignLeft="@id/editText" android:layout_alignRight="@id/editText" android:layout_below="@+id/editText" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/textView" android:gravity="center" android:textSize="20sp" android:text="登陆界面"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="取消" android:id="@+id/button" android:layout_below="@+id/editText2" android:layout_alignParentRight="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="确定" android:id="@+id/button3" android:layout_toLeftOf="@id/button" android:layout_alignBottom="@+id/button" /> </RelativeLayout>

152025_8r6S_2861931.png

 

转载于:https://my.oschina.net/316258954/blog/725656

最后

以上就是凶狠滑板最近收集整理的关于Android移动开发--相对布局的全部内容,更多相关Android移动开发--相对布局内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部