Hello I have a solution regarding this can you try using fonts in this way ... I Have implemented this in my Project ...
Steps:
- Make a Package (com.fontUtils.fonts)
- Make the Font Files Like For TextView ,
EditText
or Button Text
For Example :
public class ButtonHelveticaBold extends Button {
Context ButtonFontContext;
public ButtonHelveticaBold(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
ButtonFontContext = context;
}
public ButtonHelveticaBold(Context context, AttributeSet attrs) {
super(context, attrs);
ButtonFontContext = context;
}
public ButtonHelveticaBold(Context context) {
super(context);
ButtonFontContext = context;
}
@Override
public void setTypeface(Typeface tf, int style) {
Typeface typeFaceHelvetica;
if (style == Typeface.BOLD) {
typeFaceHelvetica = Typeface.createFromAsset(getContext().getAssets(), "fonts/helvetica_bold_neue.ttf");
} else {
typeFaceHelvetica = Typeface.createFromAsset(getContext().getAssets(), "fonts/helvetica_neue_regular.ttf");
}
super.setTypeface(typeFaceHelvetica);
}
}
3 : Use this in XML Like this way:
<com.fontUtils.fonts.ButtonHelveticaBold
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>