0

Everyone

I want to apply my custom font to whole application not just a textview or not for an activity. if it is possible make just change in manifest file so it is easy for me.

so help me out.

  • Possible duplicate [Is it possible to set font for entire Application?](http://stackoverflow.com/questions/2711858/is-it-possible-to-set-font-for-entire-application) – MChaker Aug 03 '15 at 13:56
  • [Here's your answer](http://stackoverflow.com/a/16883281/2319542) – Sash_KP Aug 03 '15 at 14:09

3 Answers3

1

You can create custom textview class and use that class whenever you need to use custom fonts.

Check this link: How to make a custom TextView?

Community
  • 1
  • 1
Bunny
  • 576
  • 4
  • 19
1

There's also a library that does this. Very simple to use and set up.

https://github.com/chrisjenx/Calligraphy

gatlingxyz
  • 781
  • 6
  • 12
0

Try this method for all activity. Or you can make this method in you utility class and use in you activity class see bellow.

Method in your utility.java file.

public static void setFont(ViewGroup group, Typeface font) {
    int count = group.getChildCount();
    View v;
    for (int i = 0; i < count; i++) {
        v = group.getChildAt(i);
        if (v instanceof TextView || v instanceof EditText
                || v instanceof Button) {
            ((TextView) v).setTypeface(font);
        } else if (v instanceof ViewGroup)
            setFont((ViewGroup) v, font);
    }
}

And then in your Activity.java file.

ll_Homescreen = (LinearLayout) findViewById(R.id.ll_Homescreen);
FontStyle = Typeface.createFromAsset(getAssets(), path of you font);
utility.setFont(ll_Homescreen, FontStyle);

I hope this will help you Happy Coding.

Android Develeoper
  • 411
  • 1
  • 6
  • 24