HighlightTextPart(textView, index, regularExpression) TextView textView = (TextView) findViewById(R.id.textView) String text = 'Hello StackOverflow From BNK!'
Then in your activity, call like the following: int index = 3 tSpan(backgroundColorSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) tSpan(textAppearanceSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) TextAppearanceSpan textAppearanceSpan = new TextAppearanceSpan(null, Typeface.BOLD_ITALIC, -1, blueColor, null) īackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(Color.GREEN)
Here is my working code that you can use to highlight some part of string: private void highlightTextPart(TextView textView, int index, String regularExpression) )