Merhabalar,

Bu makalemde  ihtiyaç duyduğumuz bir konudan bahsedeceğim. Android activity yada fragment içerisinde oluşturduğumuz tüm metin fontlarını set etmek oldukça zaman kaybettirecektir. Birden fazla activity yada fragment içindeki tüm metinleri tek tek set etmek oldukça zor olacaktır. Activity yada fragment içindeki tüm metinleri tek satırda değiştirmenizi sağlıyor.

 

Hello,

I’m talking about an issue that we need this in my article. We’ve created in fragments or Android activity will lose a lot of time to set all text fonts. All texts in more than one activity or fragments will be very difficult to individually set. All texts or fragments of activity allows you to change a single line.

 

  

public static void applyFont(final Context context, final View root, final String fontName) {
        try {
            if (root instanceof ViewGroup) {
                ViewGroup viewGroup = (ViewGroup) root;
                for (int i = 0; i < viewGroup.getChildCount(); i++)
                    applyFont(context, viewGroup.getChildAt(i), fontName);
            } else if (root instanceof TextView)
                ((TextView) root).setTypeface(Typeface.createFromAsset(context.getAssets(), fontName));
        } catch (Exception e) {

            e.printStackTrace();
        }

 

Source Code Download – Kaynak Kod İndir