0

I got this string resource:

<string name="about_app_text"><b>%1$s</b> some text.\n\n
        <b>%2$s, text</b>, more text.</string>

The text inside the <b> tag does not get bold. Why is that?

3
  • 1
    please add code where you are converting into html and displaying it into textview Commented Sep 18, 2017 at 12:12
  • please go through to this link developer.android.com/guide/topics/ui/look-and-feel/themes.html Commented Sep 18, 2017 at 12:15
  • wrap your string with [![CDATA]] Commented Sep 18, 2017 at 12:15

2 Answers 2

1
<string name="about_app_text"><![CDATA[<b>%1$s</b> some text.\n\n
    <b>%2$s, text</b>, more text.]]></string>

then parse as Spannable

        Spanned spanned = Html.fromHtml(getString(R.string.about_app_text));
textView.setText(Spanned);
Sign up to request clarification or add additional context in comments.

Comments

0

you can try this

YourTextview.setText(Html.fromHtml(getResources().getString(R.string. about_app_text)));

string resource:

<string name="about_app_text"><![CDATA[<b>%1$s</b> some text.\n\n
        <b>%2$s, text</b>, more text.]]></string>

2 Comments

It seems to work, but cancels the affect of the new line character (\n). Do you know why?
You have exited "string" syntax and have entered into "html" syntax. Instead of using \n for a new line use the <p></p> tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.