1. 转义字符的显示形式

Android的转义字符通过unicode编码来表示。常用的显示形式有Hex形式和HTML形式。

常见的转义字符如下:字符

HTML

Hex

半角空格(半角符号)

\u0020

全角空格(中文符号)

\u3000

首行缩进

\u3000\u3000

&

&

\u0026

@

@

\u0040

%

&37;

\u25

在布局文件中使用转义字符,需要使用HTML形式:<?xml version="1.0" encoding="utf-8"?>

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="姓  名" />

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="电话号码" />

而在string.xml中,则需要使用Hex形式:<?xml version="1.0" encoding="utf-8"?>

姓\u3000\u3000名

电话号码

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐