ITPub博客

首页 > 应用开发 > IT综合 > 直播软件开发是怎样控制文字水平间距的

直播软件开发是怎样控制文字水平间距的

IT综合 作者:云豹科技阿星 时间:2021-09-14 16:51:32 0 删除 编辑

如果直播软件开发,要想实现Android TextView之类的文字保持间距,那么需要设置android:letterSpacing,android:letterSpacing的值是一个浮点数,为标准字体的倍数作为间距。写一个小demo示例。
Xml布局代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Zhang Phil CSDN 默认" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:letterSpacing="0.1"
        android:text="Zhang Phil CSDN 0.1" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:letterSpacing="0.2"
        android:text="Zhang Phil CSDN 0.2" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:letterSpacing="0.3"
        android:text="Zhang Phil CSDN 0.3" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:letterSpacing="0.4"
        android:text="Zhang Phil CSDN 0.4" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:letterSpacing="0.5"
        android:text="Zhang Phil CSDN 0.5" />
</LinearLayout>

这样就可以实现直播软件开发控制文字间距了。

声明:本文由云豹科技转发自开开心心过博客,如有侵权请联系作者删除


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69982461/viewspace-2792051/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-08-24

  • 博文量
    239
  • 访问量
    115552