Android控制文字水平间距android:letterSpacing

附录文章1实现的是Android的文字在水平方向的缩放,然而不是水平方向的文字间距。如果要想实现Android TextView之类的文字保持间距,那么需要设置android:letterSpacing,android:letterSpacing的值是一个浮点数,为标准字体的倍数作为间距。写一个小demo示例。
Xml布局代码:

[html]  view plain  copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical">  
  6.   
  7.     <TextView  
  8.         android:layout_width="wrap_content"  
  9.         android:layout_height="wrap_content"  
  10.         android:text="Zhang Phil CSDN 默认" />  
  11.   
  12.     <TextView  
  13.         android:layout_width="wrap_content"  
  14.         android:layout_height="wrap_content"  
  15.         android:letterSpacing="0.1"  
  16.         android:text="Zhang Phil CSDN 0.1" />  
  17.   
  18.     <TextView  
  19.         android:layout_width="wrap_content"  
  20.         android:layout_height="wrap_content"  
  21.         android:letterSpacing="0.2"  
  22.         android:text="Zhang Phil CSDN 0.2" />  
  23.   
  24.     <TextView  
  25.         android:layout_width="wrap_content"  
  26.         android:layout_height="wrap_content"  
  27.         android:letterSpacing="0.3"  
  28.         android:text="Zhang Phil CSDN 0.3" />  
  29.   
  30.     <TextView  
  31.         android:layout_width="wrap_content"  
  32.         android:layout_height="wrap_content"  
  33.         android:letterSpacing="0.4"  
  34.         android:text="Zhang Phil CSDN 0.4" />  
  35.   
  36.     <TextView  
  37.         android:layout_width="wrap_content"  
  38.         android:layout_height="wrap_content"  
  39.         android:letterSpacing="0.5"  
  40.         android:text="Zhang Phil CSDN 0.5" />  
  41.   
  42. LinearLayout>  


代码运行结果:


附录文章:
1,《Android控制水平方向字体缩放android:textScaleX》链接地址:http://blog.csdn.net/zhangphil/article/details/51306064 

更多相关文章

  1. 简述修改logo以及文字
  2. Android(安卓)ListView 设置
  3. Android(安卓)ScrollView滚动条
  4. Android(安卓)GridView 使用示例
  5. Android——实现两个控件水平居中
  6. Android文字的阴影效果
  7. android:text 文字阴影设置
  8. 短视频源码,实现文字横向移动效果(跑马灯效果)
  9. Android中TextView中加图片,超链接,部分字或者背景变色。。。不断

随机推荐

  1. Android视图的截图
  2. Android中MVC、MVP、MVVM模式
  3. Android之Notification类(浅谈)
  4. 谷歌Android美国市场份额赶超苹果iPhone
  5. Android(安卓)Studio Gradle 下载慢问题
  6. Android三种基本的加载网络图片方式
  7. android常用开源库volly下载
  8. App自动化解决方案 [开源项目] 基于Appiu
  9. Android(安卓)Animation之补间动画
  10. Android详细的对话框AlertDialog.Builder