如何使用自定义字体在String.xml文件 [英] How to use custom font in String.xml file

查看:130
本文介绍了如何使用自定义字体在String.xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用以下code在String.xml file.Now我的问题是在这里,我已经使用字形脸Aerial.So有什么办法,我可以使用通过空中here..suppose我的自定义字体,而不是我的自定义字体是aa.ttf ......所以我怎么可以在这里使用。 我的code是

 <字符串名称=strt_dialog_desc>在开始监视preSS并按住其最新的周期开始之日起<![CDATA [<字型=天线和GT;]]>点击OptionMenu求助<![CDATA [< / FONT>]]>< /串>
 

解决方案

//放入资产文件夹中的字体

  TextView的电视=(TextView中)findViewById(R.id.custom);
字样的脸= Typeface.createFromAsset(getAssets(),字体/ aerial.ttf);

tv.setTypeface(面);
tv.setText(R.string.strt_dialog_desc);
 

I have use following code in String.xml file.Now my question is here i had use font face as Aerial.So is there any way where i can use my custom font instead of using aerial here..suppose my custom font is aa.ttf...so how that can i use here. My code is

<string name="strt_dialog_desc">To start monitoring press and hold the date on which the latest cycle started.<![CDATA[<font face=Aerial>]]>Click OptionMenu for help!<![CDATA[</font>]]></string>

解决方案

// place your font in assets folder

TextView tv=(TextView)findViewById(R.id.custom);
Typeface face=Typeface.createFromAsset(getAssets(),"fonts/aerial.ttf");

tv.setTypeface(face);
tv.setText(R.string.strt_dialog_desc);

这篇关于如何使用自定义字体在String.xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆