views:

687

answers:

1

Hi is possible to Highlight text in a TextView or WebView????

I see is possible in a EditText

HIghligh text in a EditText

I'd like to do the same in TextView or WebView thats Possible???

Alexi

+3  A: 

enable TextView's Spannable storage! by default Spannable storage in EditText is true.

so

TextView TV = (TextView)findViewById(R.id.text);
TV.setText("Italic, highlighted, bold.", TextView.BufferType.SPANNABLE);

Spannable WordtoSpan = (Spannable) TV.getText();

WordtoSpan.setSpan(new BackgroundColorSpan(0xFFFFFF00), 8, 19, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

TV.setText(WordtoSpan);
Jorgesys