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" />
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With