Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 字体、大小动态_Android_Fonts_Size - Fatal编程技术网

Android 字体、大小动态

Android 字体、大小动态,android,fonts,size,Android,Fonts,Size,我想显示一个字符串,其中包含一些动态和静态数据。我想为动态数据使用常规自定义字体,为静态数据使用浅色字体 下面是我在string.xml中提到的字符串 <string name="my_string"> <![CDATA[<b><font color=#000000> %1$s </font></b>]]> posted a<![CDATA[<b><font color=#000000> So

我想显示一个字符串,其中包含一些动态和静态数据。我想为动态数据使用常规自定义字体,为静态数据使用浅色字体

下面是我在string.xml中提到的字符串

<string name="my_string"> <![CDATA[<b><font color=#000000> %1$s </font></b>]]>  posted a<![CDATA[<b><font color=#000000> Something </font></b>]]> that matches your preferences at</string>
%1$s]]>发布了与您的首选项相匹配的内容]]>

我在textview中声明了浅字体,但我如何为动态数据指定常规字体。

您可以使用“设置字体”方法在文本视图上应用浅字体,然后在其他具有常规样式或粗体样式的文本上应用spannable类。所以它看起来就像你想要的

tView.setTypeface(lightTypefaceObject);

SpannableString spannablecontent=new SpannableString("Normal Font Style Text");
spannablecontent.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 
                         0,spannablecontent.length(), 0);
// set Text here
tView.setText(spannablecontent);

为此使用Spanable类。检查这个-我已经看过了所有的Spanable示例,但它确实为我提供了自定义字体呈现的提示。