0

Is there a way to make a given text fill up the entire TextView width no matter on the length of the text by stretching the spaces between characters, similar to how word does so.

Abhimanyu
  • 5,260
  • 2
  • 25
  • 64
Eddie
  • 65
  • 2
  • 8

2 Answers2

1

Your options are pretty limited with TextView.

SUGGESTION: Try WebView (or equivalent), and you might be able to do something like this:

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

div {
  text-align: justify;
}

div:after {
  content: "";
  display: inline-block;
  width: 100%;
}
FoggyDay
  • 11,247
  • 4
  • 25
  • 40
1

Based on width of your TextView, calculate new letter spacing then use TextView.setLetterSpacing(float letterSpacing).

See https://developer.android.com/reference/android/widget/TextView.html#setLetterSpacing(float) for more information.

TaQuangTu
  • 1,734
  • 2
  • 12
  • 26