Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
812 views
in Technique[技术] by (71.8m points)

textview - Android: How to wrap text by chars? (Not by words)

For instance:

This is foo text for wrapping text in TextView

The way that TextView wraps is:

This is foo text for
wrapping text in ...

I want this:

This is foo text for wr
apping text in TextView
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's a bit hacky, but you could replace spaces with the unicode no-break space character (U+00A0). This will cause your text to be treated as a single string and wrap on characters instead of words.

myString.replace(" ", "u00A0");


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...