2
如果设备具有自定义字体集,则需要设置该自定义字体(如在samsung s3和其他设备中),否则我需要设置Roboto。我知道如何设置这两种字体,但我需要检查是否存在自定义字体集的情况。问题不在于使用createFromAssets方法进行设置。如何检查Android设备是否具有自定义字体集
这是我用过
private static final Typeface lightTypeface = Typeface.createFromAsset(ChatApplication
.getContext().getAssets(), "fonts/Roboto-Light.ttf");
private static final Typeface mediumTypeface = Typeface.createFromAsset(ChatApplication
.getContext().getAssets(), "fonts/Roboto-Medium.ttf");
private static final Typeface boldTypeface = Typeface.createFromAsset(ChatApplication
.getContext().getAssets(), "fonts/Roboto-Bold.ttf");
private static final Typeface regularTypeface = Typeface.createFromAsset(ChatApplication
.getContext().getAssets(), "fonts/Roboto-Regular.ttf");
public static Typeface getLightTypeface() {
return lightTypeface;
}
public static Typeface getMediumTypeface() {
return mediumTypeface;
}
public static Typeface getBoldTypeface() {
return boldTypeface;
}
public static Typeface getRegularTypeface() {
return regularTypeface;
}
我并不需要防止在三星设备的自定义字体的代码。我需要保持它按照用户的选择,但设置为Roboto其他设备。请帮助。我看着这个问题并没有真正帮助 – 2014-10-08 05:30:03
你有没有试过,它不工作?对我来说,这是自动的 – 2014-10-08 06:53:08
它的工作原理是当我使用typeface.DEFAULT时显示自定义字体,但我需要使用Roboto,如上面所示,在所有其他情况下。总之,我需要做的是检查设备是否具有自定义字体集并基于该默认返回或返回roboto。 – 2014-10-08 07:15:25