简体   繁体   中英

how to change color of the selected words in EditText

I'm creating a text editor, and i wont to able users to select some words in EditText and change color of the selected words, How can I do that? Or how can i understand which words, user selected? Thanks

Use getSelectionStart and getSelectionEnd to get the active selection.

Use SpannableString and SpannableString.setSpan to colorize the selection using a ForegroundColorSpan .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM