<com.your.package.BrandTextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="View with custom font"/><com.your.package.BrandTextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textStyle="bold"android:text="View with custom font and bold typeface"/>
publicstaticvoidapplyFont(finalContextcontext,finalViewroot,finalStringfontName){try{if(rootinstanceofViewGroup){ViewGroupviewGroup=(ViewGroup)root;for(inti=0;i<viewGroup.getChildCount();i++)applyFont(context,viewGroup.getChildAt(i),fontName);}elseif(rootinstanceofTextView)((TextView)root).setTypeface(Typeface.createFromAsset(context.getAssets(),fontName));}catch(Exceptione){Log.e(TAG,String.format("Error occured when trying to apply %s font for %s view",fontName,root));e.printStackTrace();}}