Sign of degree (as in degrees Celsius / Fahrenheit) in TextView

Is there a way to include a small round degree symbol in a TextView? This would be for temperature readings, as in degrees Celsius or Fahrenheit. I am wondering if someone has done this programmatically before.

+50
android textview
Jul 22 '10 at 18:18
source share
4 answers

There is a Unicode character for degrees Celsius, which you can use in Java: \u2103 . For Fahrenheit, you can use \u2109 .

I confirmed that this works on Android Nexus S running Android version 2.3.6.

Code example:

 temperatureValue.setText((result) + " \u2109"); 
+88
Jul 22 '10 at 18:27
source share

If someone wants only the sign of a small circle without a letter, he can use:

 \u00B0 

Source: Unicode character "DEGREE SIGN"

+15
Mar 06 '16 at 13:15
source share

in action 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" 
+6
Mar 05 '17 at 15:34
source share

If you only need the circle symbol (o), you can copy the code below.

 char tmp = 0x00B0; temperature.setText("60"+tmp); 

Hope this helps :)

0
Jun 02 '17 at 7:30
source share



All Articles