博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android中RelativeLayout的字符水平(垂直居中)对齐
阅读量:6284 次
发布时间:2019-06-22

本文共 2245 字,大约阅读时间需要 7 分钟。

【背景】

此处Android中显示出来的TextView中的内容,水平中间不对其。

想要实现水平居中对齐。

【折腾过程】

1.搜:

android RelativeLayout horizontal center

参考:

试过了:

android:layout_centerHorizontal="true"

但没用。

2.后来看到:

去试了试:

android:layout_centerVertical="true"

才明白:

我上面是错误的搜了horizontal ,实际上该去搜Vertical才对。

现在效果是所需要的了:

android text horizontal center align

【总结】

想要水平居中对齐,则只需要去设置:

android:layout_centerVertical="true"

即可。

【引申】

更多的其他参数,可以去官网:

中找到:

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.

至于每个都是什么效果,就可以自己去多试试就知道了。

转载地址:http://kdxva.baihongyu.com/

你可能感兴趣的文章
树莓派3链接wifi
查看>>
js面向对象编程
查看>>
Ruby中类 模块 单例方法 总结
查看>>
jQuery的validate插件
查看>>
5-4 8 管道符 作业控制 shell变量 环境变量配置
查看>>
Enumberable
查看>>
开发者论坛一周精粹(第五十四期) 求购备案服务号1枚!
查看>>
validate表单验证及自定义方法
查看>>
javascript 中出现missing ) after argument list的错误
查看>>
使用Swagger2构建强大的RESTful API文档(2)(二十三)
查看>>
Docker容器启动报WARNING: IPv4 forwarding is disabled. Networking will not work
查看>>
(转)第三方支付参与者
查看>>
程序员修炼之道读后感2
查看>>
DWR实现服务器向客户端推送消息
查看>>
js中forEach的用法
查看>>
Docker之功能汇总
查看>>
!!a标签和button按钮只允许点击一次,防止重复提交
查看>>
(轉貼) Eclipse + CDT + MinGW 安裝方法 (C/C++) (gcc) (g++) (OS) (Windows)
查看>>
还原数据库
查看>>
作业调度框架 Quartz.NET 2.0 beta 发布
查看>>