在项目中,有时候在一些控件(如Button、TextView)中要添加一些符号,如下图所示:
 
                        
这个时候可以使用图片的方式来显示,不过这些可以直接使用Unicode码就直接显示出来了。
4个箭头图标的代码如下:
<RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_horizontal" > <Button android:id="@+id/scroll_left" android:layout_width="40dip" android:layout_height="40dip" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:text="@string/left_arrow" /> <Button android:id="@+id/scroll_up" android:layout_width="40dip" android:layout_height="40dip" android:layout_alignParentTop="true" android:layout_toRightOf="@id/scroll_left" android:text="@string/up_arrow" /> <Button android:id="@+id/scroll_down" android:layout_width="40dip" android:layout_height="40dip" android:layout_below="@id/scroll_up" android:layout_toRightOf="@id/scroll_left" android:text="@string/down_arrow" /> <Button android:id="@+id/scroll_right" android:layout_width="40dip" android:layout_height="40dip" android:layout_centerVertical="true" android:layout_toRightOf="@id/scroll_down" android:text="@string/right_arrow" /> </RelativeLayout>
皇冠和音乐图标代码如下:
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/music" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/crown" /> </LinearLayout>
上面的几个字符串值为:
<string name="music">/u265A</string><string name="crown">/u266B</string><string name="left_arrow">/u2190</string><string name="up_arrow">/u2191</string><string name="down_arrow">/u2193</string><string name="right_arrow">/u2192</string>
从网上找到了部分关于特殊符号的Unicode码值,记录下来,以备后用,如下所示: 
用Android的string.xml中使用Unicode表示符号的话,就使用下面的JS相关的Unicode值即可
⇠ 箭头类
| 符号 | UNICODE | 符号 | UNICODE | ||||
|---|---|---|---|---|---|---|---|
| HTML | JS | CSS | HTML | JS | CSS | ||
| ⇠ | ⇠ | /u21E0 | /21E0 | ⇢ | ⇢ | /u21E2 | /21E2 | 
| ⇡ | ⇡ | /u21E1 | /21E1 | ⇣ | ⇣ | /u21E3 | /21E3 | 
| ↞ | ↞ | /u219E | /219E | ↠ | ↠ | /u21A0 | /21A0 | 
| ↟ | ↟ | /u219F | /219F | ↡ | ↡ | /u21A1 | /21A1 | 
| ← | ← | /u2190 | /2190 | → | → | /u2192 | /2192 | 
| ↑ | ↑ | /u2191 | /2191 | ↓ | ↓ | /u2193 | /2193 | 
| ↔ | ↔ | /u2194 | /2194 | ↕ | ↕ | /u2195 | /2195 | 
| ⇄ | ⇄ | /u21C4 | /21C4 | ⇅ | ⇅ | /u21C5 | /21C5 | 
| ↢ | ↢ | /u21A2 | /21A2 | ↣ | ↣ | /u21A3 | /21A3 | 
| ⇞ | ⇞ | /u21DE | /21DE | ⇟ | ⇟ | /u21DF | /21DF | 
| ↫ | ↫ | /u21AB | /21AB | ↬ | ↬ | /u21AC | /21AC | 
| ⇜ | ⇜ | /u21DC | /21DC | ⇝ | ⇝ | /u21DD | /21DD | 
| ↚ | ↚ | /u219A | /219A | ↛ | ↛ | /u219B | /219B | 
| ↮ | ↮ | /u21AE | /21AE | ↭ | ↭ | /u21AD | /21AD | 
| ⇦ | ⇦ | /u21E6 | /21E6 | ⇨ | ⇨ | /u21E8 | /21E8 | 
| ⇧ | ⇧ | /u21E7 | /21E7 | ⇩ | ⇩ | /u21E9 | /21E9 | 
| ▲ | ▲ | /u25B2 | /25B2 | ► | ► | /u25BA | /25BA |