Android TextView对齐的小技巧
来源:互联网 发布:nginx 指定ip访问 编辑:程序博客网 时间:2024/05/18 02:35
在写Android布局文件时, 经常碰到如下图的TextView左右对齐的情况, 即姓名和手机号码纵向对齐。
第一种方法: 在姓和名之间加空格, 但是如果用键盘的空格会在一些机型上对齐、一些机型上不对齐。
\u3000是全角空格; \u0020是半角空格,效果跟在英文输入法下直接敲键盘空格一样。 这里要用全角空格, 占位一个汉字。
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="姓\u3000\u3000名" android:textColor="#6e6e6e" android:textSize="13dp" />
第二种方法: 比较low。 用3个TextView, 第一个是“姓”、第二个是invisible(利用不显示但占位的特性)的2个汉字如“姓名”, 第三个是“名”。
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓"
android:textColor="#6e6e6e"
android:textSize="13dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="姓名"
android:visibility="invisible"
android:textColor="#6e6e6e"
android:textSize="13dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="名"
android:textColor="#6e6e6e"
android:textSize="13dp" />
- Android TextView对齐的小技巧
- android textview小技巧
- Android小技巧——TextView的一些小技巧
- Android小技巧——TextView的一些小技巧
- Android两端对齐的TextView
- TextView的一些小技巧
- textview使用的小技巧
- android中textview的左右对齐
- Android TextView两端对齐
- Android TextView两端对齐
- TextView 小技巧
- 两端对齐的TextView
- Android TextView 文字实现左右对齐(分散对齐、两端对齐)的一个思路
- 关于android TextView在不需要较焦点的情况下,自动滚动文本实现小技巧
- android TextView 分散对齐(两端对齐)
- Android TextView两端对齐、文本两端对齐
- Android TextView 文本自动对齐
- Android TextView显示文字对齐
- Quartz和分布式定时任务
- 大三暑假实习---sass学习
- 关于C++ const 的全面总结
- HIHO #1182 : 欧拉路·三(有向图 输出欧拉路径)
- wmic添加环境变量会多出一些重复的内容
- Android TextView对齐的小技巧
- html 下拉菜单 被图片遮挡住了
- eclipse常用快捷键
- 【Hadoop】Hive优化之——控制hive任务中的map数和reduce数
- CListView操作
- 创建一个springboot项目
- Java路
- 常用linux命令
- 【jzoj4714】【公约数】【数论】