Android中RelativeLayout的字符水平(垂直居中)对齐
【背景】
此处Android中显示出来的TextView中的内容,水平中间不对其。
想要实现水平居中对齐。
【折腾过程】
1.搜:
android RelativeLayout horizontal center
参考:
android – TextView horizontal center in RelativeLayout – Stack Overflow
试过了:
- android:layout_centerHorizontal="true"
但没用。
2.后来看到:
relativelayout – Android Relative Layout Align Center – Stack Overflow
去试了试:
- android:layout_centerVertical="true"
才明白:
我上面是错误的搜了horizontal ,实际上该去搜Vertical才对。
现在效果是所需要的了:
【总结】
想要水平居中对齐,则只需要去设置:
- android:layout_centerVertical="true"
即可。
【引申】
更多的其他参数,可以去官网:
RelativeLayout.LayoutParams | Android Developers
中找到:
Attribute Name |
Related Method |
Description |
Positions the bottom edge of this view above the given anchor view ID. |
||
Positions the baseline of this view on the baseline of the given anchor view ID. |
||
Makes the bottom edge of this view match the bottom edge of the given anchor view ID. |
||
Makes the end edge of this view match the end edge of the given anchor view ID. |
||
Makes the left edge of this view match the left edge of the given anchor view ID. |
||
If true, makes the bottom edge of this view match the bottom edge of the parent. |
||
If true, makes the end edge of this view match the end edge of the parent. |
||
If true, makes the left edge of this view match the left edge of the parent. |
||
If true, makes the right edge of this view match the right edge of the parent. |
||
If true, makes the start edge of this view match the start edge of the parent. |
||
If true, makes the top edge of this view match the top edge of the parent. |
||
Makes the right edge of this view match the right edge of the given anchor view ID. |
||
Makes the start edge of this view match the start edge of the given anchor view ID. |
||
Makes the top edge of this view match the top edge of the given anchor view ID. |
||
If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc. |
||
Positions the top edge of this view below the given anchor view ID. |
||
If true, centers this child horizontally within its parent. |
||
If true, centers this child horizontally and vertically within its parent. |
||
If true, centers this child vertically within its parent. |
||
Positions the start edge of this view to the end of the given anchor view ID. |
||
Positions the right edge of this view to the left of the given anchor view ID. |
||
Positions the left edge of this view to the right of the given anchor view ID. |
||
Positions the end edge of this view to the start of the given anchor view ID. |
至于每个都是什么效果,就可以自己去多试试就知道了。
Android中RelativeLayout的字符水平(垂直居中)对齐的更多相关文章
- CSS3中flexbox如何实现水平垂直居中和三列等高布局
最近这些天都在弥补css以及css3的基础知识,在打开网页的时候,发现了火狐默认首页上有这样一个东西.
- css水平垂直居中对齐方式
1.文字或者内联元素的垂直水平居中对齐 css属性 -- 水平居中:text-aligin:center; 垂直居中: line-height:height; 例子:. html: <div c ...
- CSS制作水平垂直居中对齐
作为前端攻城师,在制作Web页面时都有碰到CSS制作水平垂直居中,我想大家都有研究过或者写过,特别的其中的垂直居中,更是让人烦恼.这段时间,我收集了几种不同的方式制作垂直居中方法,但每种方法各有千秋呀 ...
- 微信小程序文字水平垂直居中对齐问题
我们知道常用的居中对齐方式有很多种例如: text-align:center; align-items:center; justify-content: center; margin: auto; # ...
- CSS制作水平垂直居中对齐 多种方式各有千秋
作为前端攻城师,在制作Web页面时都有碰到CSS制作水平垂直居中,我想大家都有研究过或者写过,特别的其中的垂直居中,更是让人烦恼.这段时间,我收 集了几种不同的方式制作垂直居中方法,但每种方法各有千秋 ...
- CSS中怎么设置元素水平垂直居中?
记录怎么使用text-align与vertical-align属性设置元素在容器中垂直居中对齐.text-align与vertical-align虽然都是设置元素内部对齐方式的,但两者的用法还是有略微 ...
- Android中RelativeLayout和LinearLayout性能分析
先看一些现象吧:用eclipse或者Android studio,新建一个Activity自动生成的布局文件都是RelativeLayout,或许你会认为这是IDE的默认设置问题,其实不然,这是由 a ...
- Android中RelativeLayout各个属性的含义
android:layout_above="@id/xxx" --将控件置于给定ID控件之上android:layout_below="@id/xxx" - ...
- Android中RelativeLayout属性详细说明
android:layout_above="@id/xxx" --将控件置于给定ID控件之上android:layout_below="@id/xxx" - ...
随机推荐
- 利用jquery进行ajax提交表单和附带的数据
1.获取表单数据: $form.serialize() 2.附带数据:input[status]=1 3.构造url链接:url = $form.attr('action') + '?input[st ...
- C# 数据结构 线性表(顺序表 链表 IList 数组)
线性表 线性表是最简单.最基本.最常用的数据结构.数据元素 1 对 1的关系,这种关系是位置关系. 特点 (1)第一个元素和最后一个元素前后是没有数据元素,线性表中剩下的元素是近邻的,前后都有元素. ...
- PAT (Basic Level) 1013. 数素数 (20)
令Pi表示第i个素数.现任给两个正整数M <= N <= 104,请输出PM到PN的所有素数. 输入格式: 输入在一行中给出M和N,其间以空格分隔. 输出格式: 输出从PM到PN的所有素数 ...
- theano中的logisticregression代码学习
1 class LogisticRegression (object): 2 def __int__(self,...): 3 4 #定义一些与逻辑回归相关的各种函数 5 6 def method1( ...
- 《agile java》First : 起步 + 章节练习题
第一章节:起步 1.创建简单Java类2.创建测试类3.使用JUnit4.学习构造函数5.重构代码 涉及知识:TDD.UML TDD: Test Driven Development, 测试驱动开发. ...
- Internship
zoj2532:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1532 题意:有n个发射点,m个中继站,然后发射点会发射一些信息 ...
- 翻译qmake文档 目录(四篇)
http://www.cnblogs.com/li-peng/p/4026133.html
- Storm学习笔记
1.如何让一个spout并行读取多个流? 方法:任何spout.bolts组件都可以访问TopologyContext.利用这个特性可以让Spouts的实例之间划分流. 示例:获取到storm集群sp ...
- 支付宝APP支付Java回调具体步骤
/** * 支付宝异步请求通知 * * @param request * @return */@RequestMapping(value = "async", method = R ...
- Spark Streaming fileStream实现原理
fileStream是Spark Streaming Basic Source的一种,用于“近实时”地分析HDFS(或者与HDFS API兼容的文件系统)指定目录(假设:dataDirectory)中 ...