lorensiuswlt / NewQuickAction

Android QuickAction
http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/
Apache License 2.0
583 stars 212 forks source link

Custom font #14

Open samchorge opened 12 years ago

samchorge commented 12 years ago

Hi Loren,

Superb code. In my project, I use custom font and use following code to apply my custom font to all controls in the layout.


public static void applyFont(final Context context, final View root, final String fontPath) { try { if (root instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) root; int childCount = viewGroup.getChildCount(); for (int i = 0; i < childCount; i++) applyFont(context, viewGroup.getChildAt(i), fontPath); } else if (root instanceof TextView) ((TextView) root).setTypeface(Typeface.createFromAsset(context.getAssets(), fontPath)); } catch (Exception e) { Log.e(TAG, String.format("Error occured when trying to apply %s font for %s view", fontPath, root)); e.printStackTrace(); }

}

I tried this introducing in your code but couldn't find the appropriate place. Can you pls guide me?

Thanks