Reputation: 22066
How can I insert &
Symbol in <TextView>
I have tried with & and Hex code but not allow me to do this.
<TextView android:layout_height="wrap_content"
android:textColor="#49515F"
android:text="Mission and Philosophy" // &
android:textStyle="bold"
android:textSize="11dp"
android:layout_width="wrap_content" />
Upvotes: 3
Views: 8623
Reputation: 1
Use \u0026 in Unicode for "&"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1 * * * \u0026" />
Output: 1 * * * &
Upvotes: 0
Reputation: 29672
please try this,
android:text="Mission & Philosophy"
It is called Escape Sequence.
Upvotes: 1
Reputation: 12684
I know if you externalize the string to string.xml you can definitely use &
to achieve the desired result. The same should work inline.
<TextView android:layout_height="wrap_content"
android:textColor="#49515F"
android:text="Mission & Philosophy"
android:textStyle="bold"
android:textSize="11dp"
android:layout_width="wrap_content" />
or
<TextView android:layout_height="wrap_content"
android:textColor="#49515F"
android:text="@string/mission_philosophy"
android:textStyle="bold"
android:textSize="11dp"
android:layout_width="wrap_content" />
Then in strings.xml
or really any xml
file under res\values
folder do:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="mission_philosophy">Mission & Philosophy</string>
</resources>
The second approach is more desirable because if you never need to localize the app, all your strings will be in one xml file.
Upvotes: 8
Reputation: 767
Did you try the ampersand followed by amp and then a semi colon? I cannot do it here because the web site converts it.
Upvotes: 0