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.
Asked
Active
Viewed 123 times
2 Answers
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
-
Is there a way to automatically set spacing to fit the entire width? – Eddie May 21 '20 at 04:05
-
1@Eddie In my best knowledge, there is no automatic method like that! – TaQuangTu May 21 '20 at 04:15