Hi there
Does anyone have experience with changing fonts in an android app?
My customer wants to have his custom font included globally in the app. What I dont want to do is subclassing all the used views that i need (Buttons, TextViews ... ) and change the font in this subclass.
My approach that works with API < 21 is based on this post: http://stackoverflow.com/questions/2711858/is-it-possible-to-set-font-for-entire-application
The problem is that it uses reflection, which is not very elegant....and that it does not work anymore with API >= 21.
I would appreciate any help or hint.
Cheers
Fabian
Never mind:
var staticTypefaceFieldName = "MONOSPACE"; var typeFace = Class.FromType (typeof (Typeface)); var customfont = Typeface.CreateFromAsset(context.Assets, @"fonts/mycustomfont.ttf"); var font = typeFace.GetDeclaredField (staticTypefaceFieldName); font.Accessible = true; font.Set (null, customFont);
Answers
@FabianEriksson Could you share some code?
Never mind: