如何在Android的XML编辑器中插入特殊字符作为文本?

时间:2021-07-25 16:52:14

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 than or equal to" symbol? Things like that.

所以,我正在写一个应用程序,使用一些数学符号。我在visual XML编辑器中做这个。有什么方法可以得到,比如说,一个积分符号,或者一个"小于或等于"的符号吗?类似这样的事情。

Thanks!

谢谢!

6 个解决方案

#1


8  

Try put they as HTML.

试着把它们作为HTML。

String htmlStringWithMathSymbols = "≤  ≥";

textView.setText(Html.fromHtml(htmlStringWithMathSymbols));

Here you can display your math symbol in textView

这里你可以在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

在这里发布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!

希望,它帮助你!

#2


13  

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;

#3


2  

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:

对于通过XML在Android中插入特殊的unicode字符(包括数学符号),您所要做的就是包含具有&#< unicode >的unicode字符的HTML代码;在XML。例如,如果您希望在与您的活动(main)对应的XML文件的按钮视图中显示数学符号“Pi”。例如,在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

然后您将在字符串中识别上面包含的字符串资源“button_pi”。xml文件如下所示。

<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)

现在,当您构建并运行代码时,您将在您的视图中看到圆周率的符号。下面的链接提供了所有统一代码字符集(包括所有特殊符号)的HTML代码的完整表

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

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

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

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

#4


1  

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

我曾经做过类似的事情,在XML文件中输入外文字符。据我所知,最好的方法是将你想要显示的文本放到字符串中。xml文件,在xml中引用为@string/your_text_declaration_here。将所有文本放入字符串中也是一种很好的做法。xml文件,不管是否有特殊字符。

#5


1  

any of the following &int; &Integral; &#x0222B; &#8747; will produce an integral sign : ∫

下列任何一个∫与积分;& # x0222B;& # 8747;将会产生一个积分符号:∫吗

∬ can be achieved with &Int; &#x0222C; ∭ can be achieved with &tint; ∮ can be achieved with &conint;

可以实现∬int;& # x0222C;∭与色彩可以实现;与&conint∮可以实现;

#6


0  

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.

有商业产品中特殊符号转换数学/源代码XML文本元素与所有类和起动器有效的XML源代码集成到应用程序中,允许你在文本元素仍有特殊字符(称为爆炸而不是XML文件),并转换为有效的XML处理。

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).

您可以从命令行使用一个免费版本,该版本还可以确保您的文件类型是指定的(例如,如果您使用a、a、o等字符,则使用ISO-8859-1,等等。

Code from the High Level Logic Project

来自高级逻辑项目的代码。

#1


8  

Try put they as HTML.

试着把它们作为HTML。

String htmlStringWithMathSymbols = "&#8804;  &#8805;";

textView.setText(Html.fromHtml(htmlStringWithMathSymbols));

Here you can display your math symbol in textView

这里你可以在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

在这里发布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!

希望,它帮助你!

#2


13  

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;

#3


2  

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:

对于通过XML在Android中插入特殊的unicode字符(包括数学符号),您所要做的就是包含具有&#< unicode >的unicode字符的HTML代码;在XML。例如,如果您希望在与您的活动(main)对应的XML文件的按钮视图中显示数学符号“Pi”。例如,在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

然后您将在字符串中识别上面包含的字符串资源“button_pi”。xml文件如下所示。

<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)

现在,当您构建并运行代码时,您将在您的视图中看到圆周率的符号。下面的链接提供了所有统一代码字符集(包括所有特殊符号)的HTML代码的完整表

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

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

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

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

#4


1  

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

我曾经做过类似的事情,在XML文件中输入外文字符。据我所知,最好的方法是将你想要显示的文本放到字符串中。xml文件,在xml中引用为@string/your_text_declaration_here。将所有文本放入字符串中也是一种很好的做法。xml文件,不管是否有特殊字符。

#5


1  

any of the following &int; &Integral; &#x0222B; &#8747; will produce an integral sign : ∫

下列任何一个∫与积分;& # x0222B;& # 8747;将会产生一个积分符号:∫吗

∬ can be achieved with &Int; &#x0222C; ∭ can be achieved with &tint; ∮ can be achieved with &conint;

可以实现∬int;& # x0222C;∭与色彩可以实现;与&conint∮可以实现;

#6


0  

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.

有商业产品中特殊符号转换数学/源代码XML文本元素与所有类和起动器有效的XML源代码集成到应用程序中,允许你在文本元素仍有特殊字符(称为爆炸而不是XML文件),并转换为有效的XML处理。

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).

您可以从命令行使用一个免费版本,该版本还可以确保您的文件类型是指定的(例如,如果您使用a、a、o等字符,则使用ISO-8859-1,等等。

Code from the High Level Logic Project

来自高级逻辑项目的代码。