Is it possible to set a custom font for entire of application?

后端 未结 25 2955
日久生厌
日久生厌 2020-11-22 02:44

I need to use certain font for my entire application. I have .ttf file for the same. Is it possible to set this as default font, at application start up and then use it else

25条回答
  •  遇见更好的自我
    2020-11-22 03:03

    I would also like to improve weston's answer for API 21 Android 5.0.

    I had the same issue on my Samsung s5, when using DEFAULT font. (with the others fonts it's working fine)

    I managed to make it working by setting the typeface ("sans" for example) in XML files, for each Textview or Button

    
    

    and in MyApplication Class :

    public class MyApplication extends Application {
        @Override
        public void onCreate() {
        TypefaceUtil.overrideFont(getApplicationContext(), "SANS_SERIF",
        "fonts/my_font.ttf");
        }
    }
    

    Hope it helps.

提交回复
热议问题