set View Typeface - Android User Interface

Android examples for User Interface:View Property

Description

set View Typeface

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 setTypeface(Typeface typeface, View view) {
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            int childs = viewGroup.getChildCount();
            for (int i = 0; i < childs; i++) {
                setTypeface(typeface, viewGroup.getChildAt(i));
            }/*ww  w . j  ava2s .c  o  m*/
        }
        if (view instanceof TextView) {
            ((TextView) view).setTypeface(typeface);
        }
    }
}

Related Tutorials