开始时如何在Android TextView中写入`@`符号

时间:2018-08-30 12:25:22

标签: android textview symbols

我想在@中写以TextView符号开头的文本。但是,当我在两个地方都将其写为硬编码并使用字符串资源时,错误显示为missing /。当我在@之前键入一些字符时,它可以正常工作。但是,我想在一开始就写它。如何实现呢?

3 个答案:

答案 0 :(得分:2)

之类的String.xml中添加Unicode字符
<string name="character">\u0040 character</string>

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

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/character"/>

此处\ u0040表示'@'符号。

答案 1 :(得分:2)

像这样\@

使用它
<string name="character">\@ character</string>

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

答案 2 :(得分:0)

按照错误提示只写“ \ @”;)(这是一个特殊字符,需要用“ \”转义)