在 TextView 中均匀 space 输出文本

Evenly space out text inside a TextView

有没有办法通过拉伸字符之间的空格,使给定的文本填满整个 TextView width,而不考虑文本的长度,类似于 word 的做法。

TextView 的选择非常有限。

建议:试试 WebView(或等效的),你也许可以做这样的事情:

Force single line of text in element to fill width with CSS

div {
  text-align: justify;
}

div:after {
  content: "";
  display: inline-block;
  width: 100%;
}

根据 TextView 的宽度,计算新的字母间距,然后使用 TextView.setLetterSpacing(float letterSpacing)

有关详细信息,请参阅 https://developer.android.com/reference/android/widget/TextView.html#setLetterSpacing(float)