Akash Raghav
Akash Raghav

Reputation: 1153

how to handle textview span style bold issue with langs having semi-characters(like hindi matra: ा ि ी ु) being seperated out?

I need to style some part of text in a TextView like making bold etc. I'm supporting multiple languages but facing an issue when the languages have dependent semi-characters like matra in Hindi which are dependent on other characters. ex : Hindi Matra: ा ि ी ु. As soon as bold or some style is applied to them, they separate out from the connected character and form a word like this -> 'बीपी मश ीन' instead of this -> 'बीपी मशीन'

Adding code below. Please help find a solution for this.

TextView tv = findViewById(R.id.text);

String keyword = "बीपी मशीन";
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(keyword);

spannableStringBuilder.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD), 7, keyword.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
tv.setText(spannableStringBuilder);

text after style applied

Upvotes: 3

Views: 74

Answers (0)

Related Questions