Android的ICS - 强制使用DroidSans作为serif字体 [英] Android ICS - Force use of DroidSans as serif font

查看:323
本文介绍了Android的ICS - 强制使用DroidSans作为serif字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人不知道如何强制使用DroidSans字体在Android应用程序作为Sans字体代替的Roboto?

Does someone know how to force the use of the DroidSans font in an android application as the sans font instead of Roboto?

显然有在的Roboto字体的错误,它无法正确显示的口音,就像下面的例子:
люди

Apparently there is a bug in the Roboto font, it does not display properly the accents, like in the following example: лю́ди

这显示正确的serif字体(这似乎是仍在DroidSerif字体)(上ю口音),但不与Sans字体(口音ю之后)!

Which display correctly (accent on the ю) with the serif font (which seems to be still the DroidSerif font), but not with the sans font (accent AFTER the ю)!

新Sans字体看起来的Roboto,我想用DroidSans代替,这是正确显示的东西。

The new sans font appears to be Roboto, and I would like to use the DroidSans instead, which is displaying things properly.

任何简单的解决方案来解决这个问题?

Any easy solution to solve that problem?

感谢在前进,

塞巴斯蒂安

推荐答案

我认为你必须将DroidSans.ttf手动添加到您的项目,然后将其设置为YOUT文本字段。

I think you will have to manually add the DroidSans.ttf to your project and then set it to yout text fields.

放入资产文件夹中的DroidSans.ttf在项目中。使用此就APLY所有TextView's(这个例子是当你有一个大胆的字体藏汉):

Put the DroidSans.ttf in the assets folder in your project. Use this to aply it to all TextView´s (this example is when you have a bold font aswell):

public static void setDroidSans(final ViewGroup view,final  Context context){

    Typeface droidFont=Typeface.createFromAsset(context.getAssets(),  "fonts/DroidSans.ttf");
    Typeface droidFontBold=Typeface.createFromAsset(context.getAssets(),  "fonts/DroidSansBold.ttf");
    for (int i = 0; i < view.getChildCount(); i++) {
        checkForTextview(view.getChildAt(i),droidFont,droidFontBold);
    }   

}

private static void checkForTextview(View view, Typeface typeface, Typeface typefaceBold){
    if(view instanceof ViewGroup){
        ViewGroup v=(ViewGroup) view;
        for (int i = 0; i < v.getChildCount(); i++) {
            checkForTextview(v.getChildAt(i),typeface,typefaceBold);
        }
    }
    else if(view instanceof TextView){
        if(((TextView)view).getTypeface() == Typeface.DEFAULT_BOLD)
            ((TextView)view).setTypeface(typefaceBold);
        else 
            ((TextView)view).setTypeface(typeface);
    }

}  

使用它的例子:

ViewGroup myRootView= (ViewGroup)findViewById(R.id.rootView);
setDroidSans(myRootView, getApplicationContext())

这篇关于Android的ICS - 强制使用DroidSans作为serif字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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