6

i want to bold a part of "" a text but i dont know how this my text:

<string name="apropos"> Le projet Marocherche : Bâtir au cœur d un portail professionnel, destiné aux entreprises marocaines, une création  conçue par des "professionnels pour des professionnels". 

Ali
  • 85
  • 1
  • 3
  • 8

4 Answers4

7

Just use like this -

String sourceString = "<b>" + id + "</b> " + name; 
mytextview.setText(Html.fromHtml(sourceString));

If you want to edit string in strings.xml, you can do it as -

<resource>
<string name="styled_welcome_message">We are <b>so</b> glad to see you.</string>
</resources>
Narendra Singh
  • 3,990
  • 5
  • 37
  • 78
3

You can use <b> and </b> tags in a string resource (along with their <i> and <u> counterparts). Depending on where and how you use the string resource, the formatting will be applied.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1

You can use SpannableStringBuilder and new StyleSpan(android.graphics.Typeface.BOLD) to format a part of the string to be Bold. You can get help here

Community
  • 1
  • 1
Mithun
  • 2,075
  • 3
  • 19
  • 26
0

You can use the html format like below:

String str = "You are about to start a video consultation with Dr. "+doctor.lastname()+", press <b>Ok</b> to proceed"; 
textview.setText(Html.fromHtml(str);
Manohar
  • 22,116
  • 9
  • 108
  • 144