设为首页 加入收藏

TOP

安卓之布局总结(二)
2019-09-01 23:26:16 】 浏览:104
Tags:安卓之 布局 总结
t;
> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="1"></Button> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="2"></Button> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="3"></Button> </LinearLayout> <!--蓝色框 --> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="2" android:text="0"> </Button> <Button android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1" android:text="."> </Button> </LinearLayout> </LinearLayout> <!--红色框,=号--> <LinearLayout android:orientation="vertical" android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="match_parent"> <Button android:layout_width="match_parent" android:layout_height="match_parent" android:text="="> </Button> </LinearLayout> </LinearLayout>

 

 

(2)相对布局

相对布局是最灵活的一种布局方式,可以相对父容器和相对与其他控件进行布局。

主要参数有:

1. 是否对齐父容器的语法格式为true/false:

例如:android:layout_alignParentLeft = “true”

2. 为于给定ID控件不同方位的语法格式:

例如:android:layout_above="@id/btn1"

@id/btn1 控件的ID必须是事前已经定义好的

 

android:layout_alignParentLeft                     该控件是否对齐父容器的左端

android:layout_alignParentRight                  该控件是否齐其父容器的右端

android:layout_alignParentTop                    该控件是否对齐父容器的顶部

android:layout_alignParentBottom              该控件是否对齐父容器的底部

android:layout_centerInParent                    该控件是否相对于父容器居中

android:layout_toLeftOf                              该控件位于给定ID控件的左方

android:layout_toRightOf                           该控件位于给定ID控件的右方

android:layout_above                    

首页 上一页 1 2 3 4 5 下一页 尾页 2/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇一起学Android之ProgressBar 下一篇android 权限库EasyPermissions

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目