我在EditText字段中使用自定义字体,但是我使用的字体只有英文字符。当我输入不同语言时,应用程序将使用该语言的默认Android字体。
是否可能为英文输入设置一种字体,为其他语言设置另一种字体?
要设置EditText字体,我执行以下操作:
mFont1 = Typeface.createFromAsset(context.getAssets(), "eraslght.ttf");
textView.setTypeface(mFont1 );
我在EditText字段中使用自定义字体,但是我使用的字体只有英文字符。当我输入不同语言时,应用程序将使用该语言的默认Android字体。
是否可能为英文输入设置一种字体,为其他语言设置另一种字体?
要设置EditText字体,我执行以下操作:
mFont1 = Typeface.createFromAsset(context.getAssets(), "eraslght.ttf");
textView.setTypeface(mFont1 );
如果你使用以下方式的strings.xml文件:
mFont1 = Typeface.createFromAsset(context.getAssets(), getString(R.strings.button_font));
textView.setTypeface(mFont1 );
您可以检查系统当前设置的语言,并为它们设置不同的字体。
mFont1 = Typeface.createFromAsset(context.getAssets(), "eraslght.ttf");
if (Locale.getDefault().getDisplayLanguage() == "en") {
textView.setTypeface(mFont1);
} else {
textView.setTypeface(mFont2);
}