set ViewGroup Font - Android User Interface

Android examples for User Interface:ViewGroup

Description

set ViewGroup Font

Demo Code


//package com.java2s;

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

public class Main {
    private static void setFont(ViewGroup vg, Typeface tf) {
        int childCount = vg.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View view = vg.getChildAt(i);
            if (view instanceof ViewGroup) {
                setFont((ViewGroup) view, tf);
            }/* ww  w  .  ja va 2  s.c o m*/
            if (view instanceof TextView) {
                ((TextView) view).setTypeface(tf);
            }
        }
    }
}

Related Tutorials