是否可以檢查Android API 8中的對象正在使用哪個族?檢查Android中的字體對象的家族
我創建的字樣一個噴漆的對象上,像這樣
//Simplified code, the user actually selects the family and style from a list
Paint paint = new Paint();
paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
我以後會希望能夠檢查家庭像這樣
Typeface tf= paint.getTypeface();
if (tf.equals(Typeface.DEFAULT) || tf.equals(Typeface.DEFAULT_BOLD)) {
//do something
} else if (...) {
//do something else
}
這並不是因爲他們無法正常工作同樣的對象,我也嘗試了tf == value
,但結果也是一樣。字體對象似乎沒有公開任何有用的幫助家庭檢測,有沒有解決方法?我只需要檢測基本Android字體(SERIF,SANS-SERIF,DEFAULT,MONOSPACE等)