to Override Font AllOver The Application I Use This
public class TypefaceOverride {
public static void override(Context context, String staticTypefaceFieldName, String fontAssetName) {
final Typeface regular = Typeface.createFromAsset(context.getAssets(), fontAssetName);
replaceFont(staticTypefaceFieldName, regular);
}
private static void replaceFont(String staticTypefaceFieldName, final Typeface newTypeface) {
try {
final Field staticField = Typeface.class.getDeclaredField(staticTypefaceFieldName);
staticField.setAccessible(true);
staticField.set(null, newTypeface);
} catch (Exception e) {
e.printStackTrace();
}
}
}
And then this method on application class
private void typeFace() {
TypefaceOverride.override(this, "DEFAULT", "iran_sans.ttf");
TypefaceOverride.override(this, "MONOSPACE", "iran_sans.ttf");
TypefaceOverride.override(this, "SERIF", "iran_sans.ttf");
TypefaceOverride.override(this, "SANS_SERIF", "iran_sans.ttf");
}
all fonts change as well , but when i
LinearLayout product = (LinearLayout) G.inflater.inflate(R.layout.product, null);
TextView txt = (TextView) product.findViewById(R.id.txt);
TextView Font Dont get Effect And I Have To set font on it
txt.setTypeface(Typefaces.get(G.context, "iran_sans.ttf"));
And Also there is RecycleView in LinearLayout That Inflated but colorEdgeEffect have wrong color (gray !)
what should i do ?
Damn Education ! , Why My English Is So Bad Finally found The Solution
https://developer.android.com/reference/android/view/LayoutInflater.html
Just Need To Add Context
LinearLayout product = (LinearLayout) G.inflater.cloneInContext(ActivityMain.this).inflate(R.layout.product, null);