Monday, January 30, 2012

How to set the typeface of a layout at a time?



ViewGroup rootVIew = (ViewGroup) findViewById(R.id.activity_planner_rootlayout);
font1 = Typeface.createFromAsset(getAssets(), "MyriadPro-Cond.ttf");



public static void setTypeFaceForChilds(ViewGroup viewGroup,Typeface typeface) {
final int childCount = viewGroup.getChildCount();

for (int i = 0; i < childCount; i++) {
View view = viewGroup.getChildAt(i);

if (view instanceof ViewGroup) {
setTypeFaceForChilds((ViewGroup) view,typeface);
} else if(view instanceof TextView){
((TextView) view).setTypeface(typeface);
}

}
}




No comments:

Post a Comment