如题,在开发中,经常会用到比如说类似于表格的排版,效果图:
这样的效果,谷歌也没给出这样效果的方法,网上查也没找到实现方法,然后想,中间用空格填充呢?试试,然后写了几个TextView对比一下,如下:
放大效果:
可以看出,不能完美对齐,这肯定不是想要的效果,然后就发现了两个占字符来实现:
 
 
 
 
他们与汉字换算关系就是1个汉字 = 4个  = 4个  = 1个  = 2个 
如下:
<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="密        码:"
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="这是测试:"
android:textSize="22sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小  密  码:"
android:textSize="22sp"
/>