如何让Android设备的默认字体? [英] how to get default Typeface of Android device?

查看:175
本文介绍了如何让Android设备的默认字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的API类的内部应用程序内的API类有自定义字体已设置例如静态

i has API class inside my application inside Api class there is custom font has been setup as static for example

    public static Typeface font_short;

        @SuppressWarnings("deprecation")
        public Api(Context c , Display d)
        {
            this.context = c ;

    //i want to change this if user want to keep using System font style or my custome 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       
        }

我想获得违约和设备的当前字样,如果用户不想用我的服装字体!

i want to get default and current Typeface of device if user don't want to use my costume font !

在活动课

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

和想法?

推荐答案

您可以用得到默认的字体:

You can get the default Typeface using:

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

您还可以获取基于指定样式的默认字体: Typeface.defaultFromStyle(INT风格)

You can also get the default Typeface based on specified style: Typeface.defaultFromStyle(int style).

更多关于这一点:这里

这篇关于如何让Android设备的默认字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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