Solve the layout disorder after setting a large font in the android4.0 System

Source: Internet
Author: User

In Android 4.0, the system can set a large font to display.ProgramThere will be layout disorder. The solution is to modify the fontscale value,CodeAs follows:

Resources resource = getresources ();
Configuration c = res. getconfiguration ();
C. fontscale = 1.0;

Res. updateconfiguration (C, resource. getdisplaymetrics ());

We recommend that you put this method in the onresume method. This ensures that the font size of the specified font can still be displayed after the program is started, is returned to the background, and the font size is changed back to the program. Fontscale default value is 1, General 4.0 set the font to a large size after the value will be 1.3, the value of reference: http://d.hatena.ne.jp/baroqueworksdev/20111029/1319879629 description:

Font size: Small

10-29 08:49:51. 004: I/activitymanager (85): config changed :{0.85310mcc260mnc en_us layoutdir = 0 sw320dp w320dp h480dp nrml port finger QWERTY/V
Tball/V s.8}



Font size: normal

10-29 08:48:50. 174: I/activitymanager (85): config changed :{1.0310mcc260mnc en_us layoutdir = 0 sw320dp w320dp h480dp nrml port finger QWERTY/V
Tball/V s.5}



Font size: Large

10-29 08:50:37. 494: I/activitymanager (85): config changed :{1.15310mcc260mnc en_us layoutdir = 0 sw320dp w320dp h480dp nrml port finger QWERTY/V
Tball/V s.9}



Font size: Extra Large

10-29 08:51:19. 314: I/activitymanager (85): config changed :{1.3310mcc260mnc en_us layoutdir = 0 sw320dp w320dp h480dp nrml port finger QWERTY/V
Tball/V s.10}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.