Android TextView两端对齐、文本两端对齐

Android TextView两端对齐、文本两端对齐如题 在开发中 经常会用到比如说类似于表格的排版 效果图 这样的效果 谷歌也没给出这样效果的方法 网上查也没找到实现方法 然后想 中间用空格填充呢 试试 然后写了几个 TextView 对比一下 如下 放大效果 可以看出 不能完美对齐 这肯定不是想要的效果 然后就发现了两个占字符来实现 nbsp 他们与汉字换算关系就是 1 个汉字 4 个

       
 <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="这是测试:" android:textSize="22sp" /> <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="密&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;码:" android:textSize="22sp" /> <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="密&#12288;&#12288;码:" android:textSize="22sp" />

这里写图片描述

 <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="这是测试:" android:textSize="22sp" /> <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="小&#160;&#160;密&#160;&#160;码:" android:textSize="22sp" />
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232042.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号