Search code examples
androidtypeface

setTypeface to all the layout at one time ...android


Is there away to set the type face to all the views(including the list view) at one time, instead of doing that for each view.thank you


Solution

  • You can use the following method to set typeface to the layouts

    public void setFont(ViewGroup group, Typeface font) {
            int count = group.getChildCount();
            View v;
            for (int i = 0; i < count; i++) {
                v = group.getChildAt(i);
                if (v instanceof TextView || v instanceof EditText || v instanceof Button) {
                    ((TextView) v).setTypeface(font);
                } else if (v instanceof ViewGroup)
                    setFont((ViewGroup) v, font);
            }
        }