Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Typeface;

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

public class Main {
    public static void setupTypeface(View view, Typeface globalFace) {
        try {
            if (view instanceof EditText) {
                ((EditText) view).setTypeface(globalFace);
            } else if (view instanceof CheckBox) {
                ((CheckBox) view).setTypeface(globalFace);
            } else if (view instanceof TextView) {
                ((TextView) view).setTypeface(globalFace);
                //((TextView) view).setLineSpacing(getPixelsFromDp(1f), 1f);
            } else if (view instanceof ViewGroup) {
                ViewGroup vg = (ViewGroup) view;
                for (int i = 0; i < vg.getChildCount(); i++) {
                    View child = vg.getChildAt(i);
                    setupTypeface(child, globalFace);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}