我的应用程序中有一个Api类。在Api类内部,有一个已经设置为静态的自定义字体。例如:
public static Typeface fontShort;
public Api(Context c, Display d) {
// I want to change this if user wants to keep using system font style or my custom style
if (shouldKeepCurrent == true) {
// Use system default font
fontTitle = // ???
} else {
// Use my costume font
fontTitle = Typeface.createFromAsset(context.getAssets(), "fonts/custom.ttf");
}
}
如果用户不想使用我的自定义字体,我希望能够获取设备的默认字体和当前字体!
在 Activity 类中:
TextView myView = (TextView) findViewById(R.id.myView);
// Change to custom font style or keep current font style
myView.setTypeface(Api.fontTitle);
有什么想法吗?