1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > android系统设置默认字体 如何获取Android设备的默认字体?

android系统设置默认字体 如何获取Android设备的默认字体?

时间:2022-12-14 14:57:20

相关推荐

android系统设置默认字体 如何获取Android设备的默认字体?

我的应用程序中有一个API类; 例如,在API类中,有一个自定义字体已设置为静态

public static Typeface font_short; @SuppressWarnings("deprecation") public Api(Context c , Display d) { this.context = c ; //I want to change this if user wants to keep using System font style or my custom style if ( keep_curren == true ) { font_title = //What to add here to get Default fonts Typeface }else //use my costume font { font_title = Typeface.createFromAsset(context.getAssets(),"fonts/custome.ttf"); } display = d; w = display.getWidth(); // deprecated h = display.getHeight(); // deprecated }

如果用户不想使用我的自定义字体,我想获取设备的默认和当前Typeface!

在活动类中

TextView blaaa = (TextView) findViewById(R.id.blaaa); //change to custome font style or keep current font style blaaa.setTypeface(Api.font_title);

有任何想法吗?

您可以使用以下方式获取默认字体:

if (keep_curren) { font_title = Typeface.DEFAULT; }

您还可以根据指定的样式获取默认的Typeface: Typeface.defaultFromStyle(int style) 。

更多相关内容: 这里 。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。