We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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
The text was updated successfully, but these errors were encountered: