Reputation: 158
I want to make Habit Number: bold , I tried the HTML tag but it didn't work. I did some research but couldn't find any. Hope someone is able to help me. Thanks!
String habitnumber = "Habit Number: " + String.valueOf(habitcounter);
String Title = habit.getTitle();
String description = habit.getDescription();
//Set text for the row
tv.setText(habitnumber+ "\n" + Title + " \n" + description + "\n --------------------");
Upvotes: 8
Views: 21647
Reputation: 627
Use this in the XML file, inside the textview
android:textStyle="bold"
Upvotes: 0
Reputation: 26198
I tried the HTML tag but it didn't work
I think that you didnt wrap your string to Html.fromHtml
solution:
You can do it with HTML using html tag for bold: <b>
String habitnumber = "<b>" + "Habit Number: " + "</b> " + String.valueOf(habitcounter);
tv.setText(Html.fromHtml(habitnumber ));
Upvotes: 21
Reputation: 3741
Like Gabe mentioned, try using the use Html.fromHtml or use spannable. Check this out: Selecting, Highlighting, or Styling Portions of Text
You could basically use html tags in your string resource like:
<resource>
<string id="@+id/styled_welcome_message"><b>your text</b></string>
</resources>
Upvotes: 0