Skip to content
Advertisement

How do I change the distance between words?

How can I change the distance between words in a string in Android Studio using the methods? I need the distance to be about half the size of the standard space.

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
    )
}

as I understand it, after BackgroundColorSpan(Color.BLACK), you can add a parameter to change the distance between words.

Advertisement

Answer

There are different kinds of spaces with different widths:


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

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement