Accessing a font under assets folder from XML file in Android

后端 未结 14 1176
暖寄归人
暖寄归人 2020-12-05 17:07

I am trying to do a application-wide font change and creating a style file to do so. In this file (below) I just want to change typeface value of TextAppearance style of And

14条回答
  •  一整个雨季
    2020-12-05 18:00

    You Have just make Public calls And attached Method like this

    public class TextViewFontType {
    
    public Typeface typeface;
    
    public void fontTextView(final TextView textView, final String fonttype) {
        typeface = Typeface.createFromAsset(textView.getContext().getAssets(), fonttype);
        textView.setTypeface(typeface);
    }
    

    have you use any where method TextView set font-family.

    public class FontList {
    
        public static final String gothicbNormal="fonts/gothicb.ttf";
        public static final String gothicbBold="fonts/gothicb.ttf";
    }
    

    made FontList calss after you have just call methods any where with pass two parameter.

提交回复
热议问题