1

I am making an application, and in that application I want to make some text which is partly bold and partly normal like this:

Cake Try this delicious cake made with carrots.

In my main.xml, I have entered this:

<LinearLayout
        android:id="@+id/itemone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="20"
        android:padding="3dp" >

        <ImageView
            android:layout_width="110dp"
            android:layout_height="85dp"
            android:src="@drawable/cake" />

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cake"
            android:textAppearance="?android:attr/textAppearanceSmall" />

    </LinearLayout>

And in my strings.xml I have entered this:

<string name="cake"><b>Cake</b>\n Try this delicious cake made with carrots.</string>

The result is not what I except. All I get is the word "Cake", and its not bold.

Buneme Kyakilika
  • 1,202
  • 3
  • 13
  • 34

1 Answers1

2

The textAppearanceSmall messes up this thing.

It takes this as the style and ignores the others. Don't include it.

There is also something that messes up, the tags the "<" and ">" should be replaced because there are special xml characters. Search for the html escape characters or fraction characters and the < should look like this: & l t ; (one word)

If you are bored you could search for CDATA in xml. There is a way in including plain text inside xml.

No need to dynamically setting the text of the TextView.

10s
  • 1,699
  • 1
  • 12
  • 14