Reputation: 1287
I write this line in the strings.xml:
<string name="Help">This<b>Caaaaaa</b> on the spot.</string>
But the characters between the <b>
tag don't become bold. What am I doing incorrectly?
PS:I just wanna make some part in the string (like "Caaaaa" above) bold.
Upvotes: 7
Views: 13601
Reputation: 45942
When you set the text of some widget to this string use the following code:
In strings.xml use this to add ur string:
<string name="Help">
<![CDATA[
This <b>Caaaaaa</b> on the spot.
]]>
</string>
In your activity
yourWidget.setText(Html.fromHtml(getString(R.string.Help)));
Upvotes: 26
Reputation: 163539
Tags in XML, for example <string>
and <b>
have no intrinsic meaning. The tag <b>
only means "bold" if the software processing the XML thinks that it means bold and treats it as meaning bold. You haven't said what software is processing the XML.
If this were HTML rather than XML, it would be a different matter.
Upvotes: 1
Reputation: 1319
I think you can't do that in string.xml file.
but you can set textStyle="bold" where you are using it.
like-
<TextView android:textSize="18dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textColor="@color/white"
android:textStyle="bold"
android:text="@string/Help"
android:id="@+id/header">
</TextView>
Upvotes: 1
Reputation: 7385
Take a look here. You can set the text style in the layout XML file.
Upvotes: 0