Bold some parts of the TextView?

I have a TextView, inside which I was writing about questions and answers. What if now I want to boldly highlight only questions like me? Maybe some code that gives you the ability to highlight the bold 0-10 text character, for example?

+2


source to share


2 answers


How about this path

textView.setText(Html.fromHtml("MyText<b>MyBoldText</b>"));

      

The output should look like this: "MyText MyBoldText "

and you can also do it using the line



<string name="myMixedText">My simple Text<b>My Bold Text<i>MyBoldItalicText</i></b></string>

      

now

textView.setText(R.string.myMixedText);

      

The result should look like this: "My Plain Text My Bold Text MyBoldItalicText "

+2


source


Your question has been answered:

Multiple TypeFaces in one text file



Just add the CustomTypefaceSpan class and use Typeface.BOLD and whatever font you want to use.

+1


source







All Articles