Android中相对布局的两个控件
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Button3"
/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/button3"
android:layout_toLeftOf="@id/button3"
android:text="Button1"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/button3"
android:layout_toRightOf="@id/button3"
android:text="Button3"
/>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button3"
android:layout_toLeftOf="@id/button3"
android:text="Button4"
/>
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button3"
android:layout_toRightOf="@id/button3"
android:text="Button5"
/>
布局结果如下图:

代码更改一下:
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Button3"
/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/button3"
android:layout_toLeftOf="@id/button3"
android:text="Button1"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/button3"
android:layout_toRightOf="@id/button3"
android:text="Button3"
/>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button3"
android:layout_alignRight="@id/button1"
android:text="Button4"
/>
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button3"
android:layout_alignRight="@id/button3"
android:text="Button5"
/>
布局结果如下图:

Android中相对布局的两个控件的更多相关文章
- Android中Chronometer 计时器和震动服务控件
Chronometer 计时器控件 首先在布局文件中添加chronometer控件:然后在mainActivity中获取到该控件 4 然后通过Button时间监听器中开启计时操作 5 chronome ...
- Android中的几个基本常用控件
Android 中常用的几大UI控件 1. TextView : 用于在界面中显示一段文本信息 <TextView android:id="@+id/text_view" / ...
- Android中的布局优化方法
http://blog.csdn.net/rwecho/article/details/8951009 Android开发中的布局很重要吗?那是当然.一切的显示样式都是由这个布局决定的,你说能不重要吗 ...
- Android 布局之LinearLayout 子控件weight权重的作用详析(转)
关于Android开发中的LinearLayout子控件权重android:layout_weigh参数的作用,网上关于其用法有两种截然相反说法: 说法一:值越大,重要性越高,所占用的空间越大: 说法 ...
- Android 布局之LinearLayout 子控件weight权重的作用详析
关于Android开发中的LinearLayout子控件权重android:layout_weigh参数的作用,网上关于其用法有两种截然相反说法: 说法一:值越大,重要性越高,所占用的空间越大: 说法 ...
- 我的Android进阶之旅------>Android中的布局优化 include、merge 、ViewStub
1.如何重用布局文件? 可以使用<include>标签引用其他的布局文件,并用android:id属性覆盖被引用布局文件中顶层节点的android:id属性值.代码如下: <!--引 ...
- Android笔记(七) Android中的布局——线性布局
我们的软件是由好多个界面组成的,而每个界面又由N多个控件组成,Android中借助布局来让各个空间有条不紊的摆放在界面上. 可以把布局看作是一个可以放置很多控件的容器,它可以按照一定的规律调整控件的位 ...
- Android中得到布局文件对象有三种方式
Android中得到布局文件对象有三种方式 第一种,通过Activity对象 View view = Activity对象.getLayoutInflater().inflater(R.layout. ...
- Android笔记(九) Android中的布局——框架布局
框架布局没有任何定位方式,所有的控件都会摆放在布局的左上角. 代码示例: framelayout.xml <?xml version="1.0" encoding=" ...
随机推荐
- MySql注释的写法
每一种语言都有它的注释方式,代码量少的时候还可以,随着代码量越来越多,代码注释的重要性也越发凸显. 在mysql中主要有三种方式: 1.常用的方式,跟在css中那些注释一样 :/* 内容 */ /* ...
- vue routes路由
mode: 'history',去掉浏览器上url前的#号
- 设置Redis集群访问密码(不停机设置)
依次登陆6个节点 cd /mysystest ./redis/bin/redis-cli -c -h 192.168.43.86 -p 7301 执行以下命令 config set masterau ...
- java对象序列化和反序列化,redis存入和获取对象
最近使用redis发现直接存储序列化后的对象更方便,现提供java序列化和反序列化的代码 1.序列化代码: public static byte[] serialize(Object object) ...
- kubernetes 集群添加node节点
kubernetes 集群添加node节点 注意,我们并不需要把新增的node ip加入到证书里重新生成!!! 下面我们以添加node03为例 一.添加集群里个节点的hostname并设置好对应主机名 ...
- [ipsec][strongswan] strongswan源码分析-- (二)rekey/reauth机制分析
目录 strongwan sa分析(二) 名词约定 rekey/reauth 机制分析 1 概述 2 reauth 3 CHILD SA rekey 4 IKE SA rekey 5 其他 stron ...
- Replica set 的选举策略之一 (转)
首先介绍一下在replica set里分为三种节点类型: 1 primary 负责client的读写. 2 secondary 作为热备节点,应用Primary的oplog读取的操作日志,和pri ...
- MySQL 主从延迟几万秒 Queueing master event to the relay log(转)
数据库版本Server version: 5.6.24-log Source distribution 问题描述 数据采集平台业务数据库由于批量灌数据导致主从延迟上万秒. 复制线程长期处于Que ...
- Locust 教程
写在 Locust 教程开始的前面 本文参考了: Locust 教程 : https://www.axihe.com/tools/locust/home.html : locust 的官方 Githu ...
- 安装 docker-compose 配置 lnmp
1.安装docker-compose 确保已经安装了docker sudo curl -L "https://github.com/docker/compose/releases/downl ...