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

前端 未结 7 810
南笙
南笙 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:12

    any of the following ∫ ∫ ∫ ∫ will produce an integral sign : ∫

    ∬ can be achieved with ∬ ∬ ∭ can be achieved with ∭ ∮ can be achieved with ∮

    0 讨论(0)
  • 2021-02-06 04:15

    There is a commercial product for converting math / source code special symbols in XML text elements to valid XML with all the classes and starter source code to integrate into applications, allowing you to have special characters remain in your text elements (called XPL files rather than XML), and convert to valid XML during processing.

    There is a free version that you can use from the command line that also ensures that your file types are as specified (for example ISO-8859-1 if you use characters like å,ä,ö, etc. s.c. latin-1 char set).

    Code from the High Level Logic Project

    0 讨论(0)
  • 2021-02-06 04:20
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="\u23F0"/>
    

    will result in showing a clock

    or in Kotlin:

    myTextView.text = "\u23F0"
    
    0 讨论(0)
  • 2021-02-06 04:22
    Use &lt; for <, &gt; for > and &amp; for &.
    

    or

    <   less than   &lt;    
    >   greater than    &gt;    
    &   ampersand   &amp;   
    ¢   cent            &cent;  
    £   pound           &pound; 
    ¥   yen         &yen;   
    €   euro            &euro;  
    §   section         &sect;  
    ©   copyright   &copy;  
    ®   registered trademark    &reg;   
    ™   trademark   &trade;
    
    0 讨论(0)
  • 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 &#<uni-code>; 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:

    <Button
        ...
        android:text="@string/button_pi"
        ...
    </Button>
    

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

    <string name="button_pi"> &#928;</string>
    

    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

    0 讨论(0)
  • 2021-02-06 04:31

    Try put they as HTML.

    String htmlStringWithMathSymbols = "&#8804;  &#8805;";
    
    textView.setText(Html.fromHtml(htmlStringWithMathSymbols));
    

    Here you can display your math symbol in textView

    Here the post http://www.hrupin.com/2011/12/how-to-put-some-special-math-symbols-in-textview-editview-or-other-android-ui-element

    Hope, it help you!

    0 讨论(0)
提交回复
热议问题