【问题标题】:How do I change the distance between words?如何更改单词之间的距离?
【发布时间】:2021-06-13 10:18:04
【问题描述】:

如何使用这些方法在 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)后面可以加一个参数来改变字间距。

【问题讨论】:

    标签: java string kotlin char whitespace


    【解决方案1】:

    有不同种类的空格具有不同的宽度


    另见:Is there an ASCII arrow that will fit seamlessly with the box-drawing characters?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-30
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多