java - Replacing default font with build tools 26 -
hi developing application targetsdkversion, buildtoolsversion 25 , changing font in whole application using code
final class fontsoverride { static void setdefaultfont(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 (nosuchfieldexception e) { e.printstacktrace(); } catch (illegalaccessexception e) { e.printstacktrace(); } } } fontsoverride.setdefaultfont(this, "monospace", "myfont.ttf"); and
<item name="android:typeface">monospace</item> but after updating api 26 , changing support libraries 26.0.2 method not working , application using android's default font. how can make work?
Comments
Post a Comment