Android examples for Graphics:Font
Change the root view font used assigned font.
//package com.java2s; import android.graphics.Typeface; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class Main { /**// w ww . j a va2 s .c o m * Change the root view font used assigned font. * * @param tf font ({@link android.graphics.Typeface}) * @param vg ViewGroup * * @see #changeFont(android.graphics.Typeface, android.view.View) */ private static void changeFont(Typeface tf, ViewGroup vg) { for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); changeFont(tf, v); } } /** * Change the root view font used assigned font. * <p> * All descendant {@link android.widget.TextView} will changed the font * </p> * * @param tf font ({@link android.graphics.Typeface}) * @param v the root view */ public static void changeFont(Typeface tf, View v) { if (v instanceof ViewGroup) { changeFont(tf, (ViewGroup) v); } else if (v instanceof TextView) { ((TextView) v).setTypeface(tf); } } }