04、Android开发基础之相对布局
来源:互联网 发布:淘宝虚拟物品仅退款 编辑:程序博客网 时间:2024/06/07 01:25
Android开发基础之相对布局
相对布局,也就是要有参照物的布局。小时候 我们上学,同学与同学之间,谁在谁的右边,谁在谁的左边!这就是相对于谁来说的!在Android中的相对布局也一样!
有两种,一种是相对于老爸来说,也就是父控件来说的,另外一种是相对于同级控件来说的!
相对布局相对于父控件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="中间"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="右上角"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:text="右下角"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="左上角"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="左下角"/></RelativeLayout>
相对布局相对于同级控件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <!--这个是中间部分--> <Button android:id="@+id/center_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="确定"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@id/center_button" android:text="我在中间的左边"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/center_button" android:layout_centerHorizontal="true" android:text="我在中间的顶部"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@id/center_button" android:text="我在中间的右边"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/center_button" android:layout_centerHorizontal="true" android:text="我在中间的底部"/></RelativeLayout>
视频下载地址
视频下载地址:
链接: https://pan.baidu.com/s/1o8G7hCe 密码: 7qnt
欢迎关注微信公众号
阅读全文
0 0
- 04、Android开发基础之相对布局
- android开发------编写用户界面之相对布局
- android开发------编写用户界面之相对布局
- android开发之-相对布局的属性
- android之相对布局
- android之相对布局
- Android之相对布局
- 【Android开发学习25】界面布局之相对布局RelativeLayout
- android布局之相对布局
- Android布局之相对布局
- Android 基础 RelativeLayout相对布局
- Android应用开发之RelativeLayout (相对布局)+梅花效果案例
- Android应用开发学习笔记之相对布局
- Android开发之相对布局管理器Relat…
- Android开发记录二之线性、表格、相对布局
- Android之RelativeLayout相对布局
- Android之RelativeLayout相对布局
- 【Android开发】布局管理器-相对布局
- oj问题
- Tony.SerialPorts.RS232简介
- mysql存储最大字段数,长度含义
- Insert or Merge(25 分)
- Linux指令用之记之-find
- 04、Android开发基础之相对布局
- win7 _Windows文件共享设置要点
- ActiveMQ——4.Spring-JmsTemplate之发送与接收
- 阿里云新手必看文章-如何领取阿里云优惠券
- storm 1.1.1 起步总结,摸索中走过的坑,如何避免输出无关信息
- [BZOJ]3676 [APIO2014] 回文串 回文自动机
- 听说写蚊帐,就可以 转到 B
- ASP.NET 服务器部署IIS程序池进程标示配置要和SQL SERVER一致,否则不能拽出数据
- android 百度地图 marker设置忽明忽暗闪烁点