Use special symbol (<, >) in layout design in Android

我的梦境 提交于 2019-12-03 12:53:02

问题


I need two navigation buttons with their texts are < and >. However, the compiler doesn't allow me use those symbols, even if I use \< and \>.

Is there anyway to put these symbol into the XML design file?


回答1:


Use &lt; for <
Use &gt; for >
Use &amp; for &.

etc.




回答2:


Use &#60; for <

Use &#62; for >

Use &#38; for &

use &#34; for "

for complete List of symbol

use &# decimal code of the symbol ; as above

Enjoy Programming..




回答3:


It is encouraged for Android programmers to store String values in res/values/strings. If you add a String here, you can reference it in your xml file like so: android:text="@string/mystring"




回答4:


Declare this in string.xml and use:

<string name="sna">Synonyms &amp; Antonyms</string>

And simply call this in:

<TextView 
    android:text="@string/s_n_a"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="@color/White"
    android:layout_gravity="center"
    android:textAppearance="?android:attr/textAppearanceLarge"/>

Use &lt; for <

Use &gt; for >



来源:https://stackoverflow.com/questions/6125160/use-special-symbol-in-layout-design-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!