Android布局管理器-从实例入手学习相对布局管理器的使用
场景
AndroidStudio跑起来第一个App时新手遇到的那些坑:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103797243
使用相对布局RelativeLayout实现简单的登录提示的布局,效果如下
注:
博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。
实现
新建之后的默认页面布局为
将其修改为RelativeLayout
相对布局只要是要有参照物,即谁在谁下方,谁在谁左边,和谁左对齐,等等。
首先新建一个TextView,并设置其ID,将其放在屏幕中间
<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="发现新的版本,您想现在更新吗?"android:id="@+id/textView1"android:layout_centerInParent="true"/>
主要通过 android:layout_centerInParent="true"/> 设置在中间。
然后将现在更新按钮通过android:layout_below="@+id/textView1"设置位于TextView的下方,通过android:layout_alignRight="@+id/textView1"/>设置与TextView右对齐。
然后再添加一个按钮使其在textView的下方以及在立即更新按钮的左边。
<Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="现在更新"android:id="@+id/button2"android:layout_below="@+id/textView1"android:layout_toLeftOf="@+id/button1"/>
完整示例代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="发现新的版本,您想现在更新吗?"android:id="@+id/textView1"android:layout_centerInParent="true"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="以后再说"android:id="@+id/button1"android:layout_below="@+id/textView1"android:layout_alignRight="@+id/textView1"/><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="现在更新"android:id="@+id/button2"android:layout_below="@+id/textView1"android:layout_toLeftOf="@+id/button1"/></RelativeLayout>
Android布局管理器-从实例入手学习相对布局管理器的使用相关推荐
- 从实例入手学习Shiro自定义Realm实现查询数据进行验证
场景 从实例入手学习Shiro与Web的整合: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/90140802 在上面已经实现整合 ...
- 从实例入手学习Shiro的会话机制
场景 从实例入手学习Shiro与Web的整合: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/90140802 在上面已经实现整合 ...
- OpenGL着色器透视变换实例-通过旋转平移调试着色器
OpenGL 着色器新手样例 带透视变换和旋转平移缩放 OpenGL着色器样例 - 最简单的顶点着色器 + 片元着色器 头文件和宏定义 全局变量部分 读取着色器 从文本中读取着色器代码 初始化着色器 ...
- Redis事务中的watch机制-从实例入手学习
场景 Redis中事务的实现流程: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/105048241 在上面学会Redis的事务的 ...
- Jquery中进行post请求时同步与异步的区别(从实例入手学习)
场景 表单中有两个输入框input在提交这个表单前需要对两个输入框进行校验. 即点击提交按钮时会经过校验的方法,此方法会post方式提交到后台,在请求后台成功后的回调方法中会对js变量进行赋值,进而决 ...
- 从实例入手学习Shiro与Web的整合
场景 Shiro官网关于Web整合文档: http://shiro.apache.org/web.html#Web-configuration W3Cschool Shiro Web集成: https ...
- 从实例入手学习使用vue+axios配置代理进行跨域访问百度音乐API
场景 如果要使用axios直接进行跨域访问是不可以的,这是就需要配置代理了,为什么要配置代理呢? 原因就是因为客户端请求服务端的数据是存在跨域问题的,而服务器和服务器之间可以相互请求数据,是没有跨域的 ...
- 从实例入手学习Vue-router的使用-实现音乐导航菜单切换
效果 实现 Vue Router 官方文档 https://router.vuejs.org/zh/guide/ 用 Vue.js + Vue Router 创建单页应用,是非常简单的.使用 Vue. ...
- 前端页面后台管理模板—代码实例
今天分享下"前端页面后台管理模板"这篇文章,文中根据实例编码详细介绍,或许对大家的编程之路有着一定的参考空间与使用价值,需要的朋友接下来跟着云南仟龙Mark一起学习一下吧.近期自身 ...
最新文章
- [Linux] ubuntu 格式化u盘
- JAVA_OA(八):springMVC对JDBC的操作小项目a
- matlab实现粗糙表面_基于分形理论的球头铣削表面形貌研究
- QT的QSignalMapper类的使用
- DevOps,到底是开发还是运维?
- C# 类的派生 输出个人信息
- mysql远程压力测试_mysql压力测试脚本实例
- java c++ python哪个好_程序员学java好还是python语言好 c++又如何
- DllImport的用法
- 通达信资金净流入公式_通达信资金净流量指标公式
- 十、基于FPGA的PCIE协议介绍(一)
- cisco2811路由器密码恢复
- spark的安装详细步骤
- ClientToScreen 和ScreenToClient
- 某程序员上线原谅宝:抓取全球不可描述网站和社交平台10万渣女
- linux proc 目录清理_/proc目录造成linux根目录爆满
- 晨控可视化标签在资产管理上的应用及优势
- 【前端面筋】终于等到你!!!
- 非奇异矩阵的多种判断方式
- SaltStack常用的模块-1
热门文章
- Distance 几何,构造(800)
- Mocha and Math 运算
- nstall.php a data,通过Typecho install.php 后门理解PHP对象注入 - 嘶吼 RoarTalk – 回归最本质的信息安全,互联网安全新媒体,4hou.com...
- Linux运维:常用的压缩解压缩命令(zip、tar)
- Hashtable TreeMap HashMap LinkedHashMap的区别
- JavaWeb 入门篇(1)Maven创建Web项目 Idea配置tomcat
- 安装es怎么在后台运行_ES备份索引数据到阿里云OSS
- java开发cs项目_本硕机械转行cs(java后端开发)上岸之路
- 6、leetcode34 在排序数组中查找元素的第一个位置和最后一个位置**
- mysql concat键值对_MySQL中concat函数