Skip to content

Instantly share code, notes, and snippets.

@SeongUgJung
Last active April 13, 2016 04:05
Show Gist options
  • Save SeongUgJung/0ee75203c1a820adc25f60ced48a0f06 to your computer and use it in GitHub Desktop.
Save SeongUgJung/0ee75203c1a820adc25f60ced48a0f06 to your computer and use it in GitHub Desktop.
set font to root view.
public class TypefaceUtil {
public static void setTextTypefaceNormal(View view, Typeface typeface) {
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
int childSize = viewGroup.getChildCount();
for (int idx = 0; idx < childSize; ++idx) {
TypefaceUtil.setTextTypefaceNormal(viewGroup.getChildAt(idx), typeface);
}
}
if (view instanceof TextView) {
TextView textView = (TextView) view;
if (textView.getTypeface() != typeface) {
textView.setTypeface(typeface);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment