简体   繁体   English

更改strings.xml中文本的文本大小

[英]Changing the text size of text in strings.xml

I was wondering if there was a way to alter the size of parts of a String in strings.xml . 我想知道是否有一种方法可以更改strings.xml String的部分大小。 In my Java code I call 在我的Java代码中,我调用

builder.setMessage(R.string.my_string)

I am wondering if there is a way to set the text size, similarly to how you can set the text to bold by doing this: 我想知道是否有一种设置文本大小的方法,类似于您可以通过以下操作将文本设置为粗体的方法:

<string name="my_string"><b>My String</b></string>

You can make use of Html.fromHtml("your html string"), to do any style you want in HTML and then show it in the textview as shown below: 您可以使用Html.fromHtml(“您的html字符串”)在HTML中执行所需的任何样式,然后在文本视图中显示它,如下所示:

Spanned htmlText = Html.fromHtml(getString(R.string.yourStringResource));
yourTextView.setText(htmlText, TextView.BufferType.SPANNABLE);

And the XML string.xml, must have the string declared as shown below: 而且XML string.xml必须具有声明的字符串,如下所示:

<string name="yourStringResource"><![CDATA[BLA BLA BLA BLA <br/> BLABA <font color="blue">COLORED HTML</font>]]></string>

Regards! 问候!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM