Ackman Ackman - 2 months ago 8
Java Question

TextView make part of text not bold

I have a TextView title. I need it showing half of text bold and other half not bold. The way I set it is shown below:

category.getName() -- > Bold
"urinary tract infection" ---->not bold

title.setText(category.getName()+ "\n(urinary tract infection)");


How do I achieve this?

Answer

You can try formatting you TextView using HTML.

title.setText(Html.fromHtml("<b>"+category.getName()+ "</b>\n(urinary tract infection)"));