Degrees symbol (as in Degrees Celsius/Fahrenheit) in a TextView
There is a Unicode symbol for Celsius degrees that you can use in Java: \u2103
. For Fahrenheit you can use \u2109
.
I have confirmed this works on Android Nexus S running Android version 2.3.6.
Example code:
temperatureValue.setText((result) + " \u2109");
If Someone wants just the little circle sign without the letter, he can use:
\u00B0
Source: Unicode Character 'DEGREE SIGN'
in Activity for Celsius
tempValue.setText((resultemp) + " \u2103");
for Fahrenheit
tempValue.setText((resultemp) + " \u2109");
for Kelvin
tempValue.setText((resultemp) + " \u212A");
for Romer
tempValue.setText((resultemp) + " \u00B0R");
In xml.file for Celsius
android:text="\u2103"
for Fahrenheit
android:text="\u2109"
for Kelvin
android:text="\u212A"
for Romer
android:text="\u00B0R"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="\u00B0"/>
If sign is not visible on android studio layout preview, you need to add
xmlns:tools="http://schemas.android.com/tools"
to the root xml element.