Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android:Make characters bold in xml

Tags:

android

xml

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.

like image 293
Rocky Avatar asked Oct 19 '11 05:10

Rocky


2 Answers

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)));
like image 87
Sherif elKhatib Avatar answered Oct 13 '22 00:10

Sherif elKhatib


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>
like image 30
Krishnendu Avatar answered Oct 13 '22 00:10

Krishnendu