How do I insert special characters as text in XML editor for Android?

前端 未结 7 830
南笙
南笙 2021-02-06 03:50

So, I\'m writing an app that involves using some mathematical symbols. I\'m doing this in the visual XML editor. Is there any way I can get, say, an integral symbol, or a \"less

7条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 04:22

    For inserting special unicode characters (including math symbols) in Android through XML, all you have to do is include the HTML code of the unicode character with the &#; in XML. For example, if you want to display the mathematical symbol 'Pi', in a button view of your XML file corresponding to your activity (main.xml for e.g.), you will have the following in main.xml:

    Then you will identify the string resource 'button_pi' included above, in the strings.xml file as detailed below

     Π
    

    Now, when you build and run your code, you will see the symbol of pi displayed nicely in your view. The links below provide the complete table of HTML code for all uni-code character set (including all the special symbols)

    http://www.w3schools.com/tags/ref_symbols.asp

    http://www.ascii.cl/htmlcodes.htm

提交回复
热议问题