set TypeFace For Child View - Android User Interface

Android examples for User Interface:View Child

Description

set TypeFace For Child View

Demo Code


//package com.java2s;

import android.graphics.Typeface;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class Main {
    public static void setTypeFaceForChilds(ViewGroup viewGroup,
            Typeface typeface) {/*  w w w . ja  v  a 2s .c o  m*/
        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);
            }

        }
    }
}

Related Tutorials