Let's say I want to add the word 'supercalifragilisticexpialidocious' to a TextView. How can I specify at what points Android may break up the word when it wraps it across multiple lines?
As an example, I only want Android to break the word at the locations specified by a hyphen as follows:
su-per-cal-i-frag-il-is-tic-ex-pi-al-i-do-cious
In this case, Android might display the word as:
supercalifrag-
ilisticexpial-
idocious
Soft Hyphen to the rescue! https://en.wikipedia.org/wiki/Soft_hyphen
First, you must set this property on a TextView:
android:hyphenationFrequency="normal"
Then you use the Soft Hypen character inside your strings:
­
Like so:
supercalifrag­ilisticexpial­idocious
扩展TextView
并实现此行为 - 没有内置方法。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.