如何在Android TextView开始时写入“@”符号

Str*_*oks 5 android symbols textview

我想@在 中编写以符号开头的文本TextView。但是,当我在两个地方将其作为硬编码并使用字符串资源编写时,错误显示missing /. 当我之前输入一些字符时@,效果很好。不过,我想先写一下。如何实现这一目标?

Pri*_*ola 10

像这样使用它\@

<string name="character">\@ character</string>
Run Code Online (Sandbox Code Playgroud)

或者您可以使用 Unicode 字符\0040


小智 3

在 String.xml 中添加 Unicode 字符,例如

<string name="character">\u0040 character</string>
Run Code Online (Sandbox Code Playgroud)

将其添加到您的文本视图中,例如:

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/character"/>
Run Code Online (Sandbox Code Playgroud)

这里 \u0040 表示“@”符号。