Degrees symbol (as in Degrees Celsius/Fahrenheit) in a TextView

Aur*_*ora 58 android textview

Is there a way to include the small circular degrees symbol to a TextView? This would be for temperature readings, as in degrees Celsius or Fahrenheit. I'm wondering if anyone has done this programmatically before.

Lui*_*ano 109

您可以在Java中使用可用于摄氏度的Unicode符号:\u2103.对于华氏,你可以使用\u2109.

我已经确认这适用于运行Android 2.3.6版的Android Nexus S.

示例代码:

temperatureValue.setText((result) + " \u2109");
Run Code Online (Sandbox Code Playgroud)

  • 如果你只想要没有C或F的度数符号,请使用`\ u00B0`. (23认同)
  • 是! 它确实有效.我在1.5模拟器和2.2模拟器上尝试过,而tv.setText("\ u2103")没有问题. (2认同)

ysh*_*hak 22

如果有人想要没有字母的小圆圈标志,他可以使用:

\u00B0
Run Code Online (Sandbox Code Playgroud)

来源: Unicode字符'DEGREE SIGN'


小智 12

在摄氏活动中

tempValue.setText((resultemp) + " \u2103");
Run Code Online (Sandbox Code Playgroud)

为华氏温度

tempValue.setText((resultemp) + " \u2109");
Run Code Online (Sandbox Code Playgroud)

为开尔文

tempValue.setText((resultemp) + " \u212A");
Run Code Online (Sandbox Code Playgroud)

为罗默

tempValue.setText((resultemp) + " \u00B0R");
Run Code Online (Sandbox Code Playgroud)

在xml.file中为摄氏度

android:text="\u2103"
Run Code Online (Sandbox Code Playgroud)

为华氏温度

android:text="\u2109"
Run Code Online (Sandbox Code Playgroud)

为开尔文

android:text="\u212A"
Run Code Online (Sandbox Code Playgroud)

为罗默

android:text="\u00B0R"
Run Code Online (Sandbox Code Playgroud)