Android Textview空格占位符以及一些其他占位符汇总

本文详细介绍了HTML中不同类型的空格字符,包括普通英文空格、不间断空格(nbsp)、中文全角空格以及不同宽度的空格单位,并展示了它们在布局中的应用,例如在TextView组件中的使用,以及如何通过这些空格实现文本间不同间距的效果。示例代码展示了在Android UI设计中如何利用这些空格调整元素间的距离。
摘要由CSDN通过智能技术生成

  == 普通的英文半角空格

  ==   ==   == no-break space (普通的英文半角空格但不换行)

  == 中文全角空格 (一个中文宽度)

  ==   == en空格 (半个中文宽度)

  ==   == em空格 (一个中文宽度)

  == 四分之一em空格 (四分之一中文宽度)

相比平时的空格( ),nbsp拥有不间断(non-breaking)特性。即连续的nbsp会在同一行内显示。即使有100个连续的nbsp,浏览器也不会把它们拆成两行。

使用如:

<TextView
                android:id="@+id/tvTitle"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dp16"
                android:layout_marginLeft="@dimen/dp15"
                android:layout_marginRight="@dimen/dp10"
                tools:text="团队总业绩&#12288;:"
                android:textColor="@color/white_ff"
                android:textSize="@dimen/sp18"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@id/linMiddle" />

<TextView
                android:id="@+id/tvCurrentTitle"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/dp16"
                android:layout_marginLeft="@dimen/dp15"
                android:layout_marginRight="@dimen/dp10"
                tools:text="本周业绩:"
                android:textColor="@color/white_ff"
                android:textSize="@dimen/sp18"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@id/tvTotalTitle" />

&#8230; 是“...”占位符

<string name="user_profile_user_name">姓名&#8195;&#8195;</string>
    <!--&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;-->

相当于后面补两个空格

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值