How to insert special characters into text in XML editor for Android?

So, I am writing an application that uses some mathematical symbols. I do this in a visual XML editor. Is there any way to get, say, an integral character or a less than or equal symbol? Such things.

Thanks!

+6
source share
6 answers

Try putting them in HTML.

String htmlStringWithMathSymbols = "≤ ≥"; textView.setText(Html.fromHtml(htmlStringWithMathSymbols)); 

Here you can display your math symbol in a textView

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

Hope this helps you!

+8
source
 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; 
+13
source

To insert Unicode special characters (including mathematical characters) into Android via XML, all you have to do is include the HTML code for the Unicode character with &#<uni-code>; in XML. For example, if you want to display the mathematical symbol "Pi" as a button of your XML file that corresponds to your activity (for example, main.xml), in main.xml there will be the following:

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

Then you specify the string resource 'button_pi' specified above in the strings.xml file as described below

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

Now, when you create and run your code, you will see that the pi symbol displays well in your view. The links below provide a complete HTML code table for the entire set of uni code characters (including all special characters)

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

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

+2
source

I once had to do something similar to this, putting foreign language characters in an XML file. The best, and as far as I know, is the only way to place the text that you want to show in the strings.xml file and refer to them in XML as @string/your_text_declaration_here . Also, as a rule, it is good practice to put all the text in a string.xml file regardless of special characters or not.

+1
source

any of the following &int; &Integral; &#x0222B; &#8747; &int; &Integral; &#x0222B; &#8747; gives the sign of the integral: & int;

& Int; can be achieved using &Int; &#x0222C; &Int; &#x0222C; & Tint; can be achieved with &tint; & Conint; can be achieved with &conint;

+1
source

There is a commercial product for converting special characters of mathematical / source code into XML text elements into valid XML with all classes and starter source code for integration into applications, allowing you to have special characters in your text elements (so-called XPL files, not XML) and convert to valid XML during processing.

There is a free version that you can use from the command line, which also ensures that your file types are specified (e.g. ISO-8859-1, if you use characters like å, ä, ö, etc. sc latin- 1 char).

Code from a high-level logic project

0
source

Source: https://habr.com/ru/post/904374/


All Articles