自定义字体在android冰淇淋三明治版本中显示不正确

时间:2016-06-17 07:20:50

标签: android fonts

enter image description here

enter image description here

嗨,大家好, 在我的应用程序中我设置了自定义字体,但问题是android冰淇淋三明治版本没有显示正确的文字或变得模糊,但在棒棒糖版本它的工作正常。什么人都知道冰淇淋三明治版本有什么问题?

对于自定义字体,我使用过TypefaceManager类及以下代码

<com.ex.new.textstyleUtil.TypefaceTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="normal"
                android:padding="@dimen/padding_2"
                android:text="@string/receiver_info"
                android:textColor="@color/mainColor"
                android:textSize="@dimen/text_16" />



public void applyTypeface(TextView textView, TextStyle textStyle){
    final Typeface typeface = getTypeface(textView.getContext(), textStyle);
    if (typeface != null) {
        textView.setTypeface(typeface);
    }}

public class TypefaceTextView extends TextView {

public TypefaceTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypefaceManager.getInstance().applyTypeface(this, context, attrs);
}

/**
 * Convenience method in case I need to change the font from code as well.
 * @param textStyle
 */
public void setTextStyle(TextStyle textStyle) {
    TypefaceManager.getInstance().applyTypeface(this, textStyle);
}}


public enum CooperHewittTextStyle implements TextStyle {

NORMAL("normal", "CooperHewitt-Book.ttf"),
BOLD("bold", "CooperHewitt-Bold.ttf");

private String mName;
private String mFontName;

CooperHewittTextStyle(String name, String fontName) {
    mName = name;
    mFontName = fontName;
}

@Override
public String getFontName() {
    return mFontName;
}

@Override
public String getName() {
    return mName;
}}

0 个答案:

没有答案