Skip to content

Instantly share code, notes, and snippets.

@nuthatch
Created May 20, 2011 19:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuthatch/983606 to your computer and use it in GitHub Desktop.
Save nuthatch/983606 to your computer and use it in GitHub Desktop.
set Typeface to all TextViews in a ViewGroup for Android
// recursively apply typeface to our textviews
static final void setTypeface(ViewGroup viewGroup, Typeface typeface)
{
if (viewGroup == null) return;
int children = viewGroup.getChildCount();
Log.d(TAG, "setTypeface " + viewGroup + " : " + children);
for (int i=0; i<children; i++)
{
View view = viewGroup.getChildAt(i);
if (view instanceof ViewGroup) setTypeface((ViewGroup)view, typeface);
if (view instanceof TextView)
{
TextView textView = (TextView) view;
textView.setTypeface(typeface);
}
}
}
Copy link

ghost commented Oct 5, 2014

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment