Android:Make characters bold in xml

后端 未结 4 1563
你的背包
你的背包 2021-01-12 20:41

I write this line in the strings.xml:

ThisCaaaaaa on the spot.

But the charac

相关标签:
4条回答
  • 2021-01-12 21:13

    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)));
    
    0 讨论(0)
  • 2021-01-12 21:17

    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>
    
    0 讨论(0)
  • 2021-01-12 21:31

    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.

    0 讨论(0)
  • 2021-01-12 21:32

    Take a look here. You can set the text style in the layout XML file.

    0 讨论(0)
提交回复
热议问题