You can check this screen short image Basically I want to applying different formats on my text, I just want to select a some text area from long string and apply like bold, underline or some other actions perform on selected text.
Asked
Active
Viewed 75 times
1 Answers
0
Here is a way to highlight text.
Spannable spannable = new SpannableString("A test message");
spannable.setSpan(new BackgroundColorSpan(Color.YELLOW), {start_index), {end_index}, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(spannable);
Here is a post that shows you how to make your text selectable and how to get the start and end index.
Get Selected Text from TextView
This is the reference to using spannable and you can use it to figure out the rest of your text changes to the string. There are many options available. https://developer.android.com/reference/android/text/style/BackgroundColorSpan

Nathan Walsh
- 358
- 2
- 4