无法将按钮文本设置为“<<<”

Cannot set button text to "<<<"

我正在尝试将 xml 中的按钮文本设置为“<<<”,但我得到 "Error:(20) Error parsing XML: not well-formed (invalid token)"

    <Button
        android:id="@+id/test"
        android:text="<<<"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />

所以我跳到我的 strings.xml 那里输入它,但这显然行不通。

<string name="abc"> <<< </string>

有解决办法吗?

这些是 html 个实体,也在 android 工作室中工作:

> can be replaced with &gt;
< can be replaced with &lt;
" can be replaced with &quot;, &ldquo; or &rdquo;
' can be replaced with &apos;, &lsquo; or &rsquo;
} can be replaced with &#125;
& can be replaced with &amp;
space can be replaced with &#160;

>使用&gt;<使用&lt;&使用&amp;,[=&apos; 17=] , &quot; 对于 "

您可以使用

< (less-than)                     &#60; or &lt;
> (greater-than)                  &#62; or &gt;
& (ampersand)                     &#38; or &amp;
' (apostrophe or single quote)    &#39; or &apos;
" (double-quote)                  &#34; or &quot;

请查看这些链接:

Predefined entities in XML

Using Special Characters in XML

Whosebug - escaping special characters like & in android xml