hosseinAmini
hosseinAmini

Reputation: 2342

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

Upvotes: 0

Views: 175

Answers (1)

cygery
cygery

Reputation: 2319

Use getSelectionStart and getSelectionEnd to get the active selection.

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

Upvotes: 4

Related Questions