1

I have implemented my own class extending the android android.widget.Button class to have a custom font used in all my buttons. To achieve this I have overridden the method setTypeface as following :

public void setTypeface(Typeface tf, int style) {
    if (!isInEditMode()) {
        super.setTypeface(Fonts.get(style, getContext()));
    }
}

This works great in all versions of android that my app supports, except on lollipop. Does anyone know what I am doing wrong for that?

alxscms
  • 3,067
  • 6
  • 22
  • 43

1 Answers1

1

I figured it out, I forgot to override the other definition of the method setTypeface. So the final working code I got is :

@Override
public void setTypeface(Typeface tf) {
    if (!isInEditMode()) {
        super.setTypeface(Fonts.get(getContext()));
    }
}

@Override
public void setTypeface(Typeface tf, int style) {
    if (!isInEditMode()) {
        super.setTypeface(Fonts.get(style, getContext()));
    }
}
alxscms
  • 3,067
  • 6
  • 22
  • 43