2

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?

Ackman
  • 1,562
  • 6
  • 31
  • 54
  • 1
    By using HTML, check [this question](http://stackoverflow.com/questions/2116162/how-to-display-html-in-textview) – Dominique Lorre Sep 15 '16 at 19:41
  • did this : title.setText(Html.fromHtml(""+serviceName+"")+"\n(urinary tract infection)"); did not work – Ackman Sep 15 '16 at 19:53
  • title.setText(Html.fromHtml(""+serviceName+"\n(ur‌​inary tract infection)")); -- if the /n is for a new line you can do -- title.setText(Html.fromHtml(""+serviceName+"
    (ur‌​inary tract infection)"));
    – Tasos Sep 15 '16 at 19:56
  • Thanks everyone got it! – Ackman Sep 15 '16 at 20:05

1 Answers1

2

You can try formatting you TextView using HTML.

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