0

In my application, I provide a setting for user to change the font of the whole application. I want when user choose one from the list, the whole application will immediately apply this font. I have search many questions related to this problem but I can't find a suitable solution. What do I have to do to achieve this? All help is appreciated!

Duc Le
  • 347
  • 2
  • 4
  • 14

1 Answers1

0

I couldnt find a solution now on.

I think the answer is

https://stackoverflow.com/a/9531442/621951

However, I am still investigating to find a solution.

I found a code may be that will be helped.

private void overrideFonts(final Context context, final View v) {

  try {

    if (v instanceof ViewGroup) {

      ViewGroup vg = (ViewGroup) v;

         for (int i = 0; i < vg.getChildCount(); i++) {

         View child = vg.getChildAt(i);

         overrideFonts(context, child);

             }
    } else if (v instanceof TextView ) {

      ((TextView) v).setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Vegur-R 0.602.otf"));

    }
   } catch (Exception e) {
  }
}
Community
  • 1
  • 1
Günay Gültekin
  • 4,486
  • 8
  • 33
  • 36