the" display "set by the system from android4.0 provides the option to set the font size. This setting directly affects the font adaptation of all sp units. Therefore, many apps instantly become invisible after setting the system font. Solution
Resources res = getresources (); configuration Config = new configuration (); config. settodefaults (); Res. updateconfiguration (config, Res. getdisplaymetrics (); although Google recommends using SP as the font unit, the actual development process usually converts Sp (PX to SP) based on the uiue design draft ). SP has different values even under the same density. For example, for devices with 1.5 DPI, if the resolution is 1.5x800, the value is usually 1.5 times (scaleddensity =), and if the resolution is X (z>), the value may be greater. This undoubtedly brings more difficulties and traps for device adaptation. Therefore, I usually recommend that you use DPI as the font unit. For some apps, you do not need to change the size of the system font, you can add the following code in the activity base class (all the activities in the app should inherit from an activity class we define): for example, contacts needs to be in COM. android. contacts. activities. transactionsafeactivity Add the following code @ override public resources getresources () {resources res = super. getresources (); configuration Config = new configuration (); config. settodefaults (); Res. updateconfiguration (config, Res. getdisplaymetrics (); Return res;} if only some interfaces are not required in the app, you can modify this method @ override public resources getresources () {If (isneedsystemresconfig ()) {return Super. getresources ();} else {resources res = super. getresources (); configuration Config = new configuration (); config. settodefaults (); Res. updateconfiguration (config, Res. getdisplaymetrics (); Return res ;}// by default, true is returned. system resources are used. If this method is not required on some interfaces, override this method and then return false in these activities; protected Boolean isneedsystemresconfig () {return true ;}