degree symbol in TextView
Question
I want to know how to make a degree symbol for an angle in a Text View (android). There are a few questions similar to this, I have tried them but they don't seem to work.
<TextView
android:id="@+id/tv_counter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="20dp"
android:text="..."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="80dp"
android:textColor="#FFA500" />
Solution
XML doesn't use C-style escapes, it uses HTML-style character entities. Try this:
android:text="50℃"
As you mention in the comment, U+2103 isn't what you want, you want this:
android:text="50°"
OTHER TIPS
In Code:
myTextView.setText ( "78" + (char) 0x00B0 );
"OR"
In XML:
android:text="50℃"
in xml - if you want just the symbol without F or C just use:
"\u00B0"
like this:
android:text="50\u00B0"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow