如何解决如何更改单词之间的距离?
如何使用这些方法更改 Android Studio 中字符串中单词之间的距离?我需要的距离大约是标准空间大小的一半。
val spanMsg = SpannableStringBuilder()
msg?.forEachIndexed { i,char ->//replacing non-printable characters
//with their code and highlighting
if (char.isControlChar()) {//checking for non-printable characters
spanMsg.appendWithSpan(" ",RelativeSizeSpan(BLOCKS_INDENT))
for(x in toHex(Character.toString(char)
.toByteArray(StandardCharsets.UTF_16BE))!!) {
spanMsg.appendWithSpan(
x,ForegroundColorSpan(Color.WHITE),BackgroundColorSpan(Color.BLACK)
)
}
fun SpannableStringBuilder.appendWithSpan(text: CharSequence,vararg what: Any) {
this.append(text)
what.forEach {
this.setSpan(
it,this.length - text.length,this.length,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
据我所知,在BackgroundColorSpan(Color.BLACK)
之后,你可以添加一个参数来改变单词之间的距离。
解决方法
有不同种类的空格,具有不同的宽度:
- →← - Tag Space
- → ← - Hair Space
- → ← - Thin Space
- → ← - Regular Space
- → ← - No-Break Space
- → ← - Punctuation Space
- → ← - Figure Space
- → ← - En Space
- → ← - Em Space
另见:Is there an ASCII arrow that will fit seamlessly with the box-drawing characters?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。