Modify the default font size of the android System

Source: Internet
Author: User

The font size of the android system is set to "font size" in "display" in "Settings". A total of four levels are provided: small, normal, large, and super large.

Select the corresponding configuration code location for the four levels

Packages/apps/setttings/res/values/arrays. xml

 
 
  1. <string-array name="entries_font_size">
  2. <item msgid="6490061470416867723">Small</item>
  3. <item msgid="3579015730662088893">Normal</item>
  4. <item msgid="1678068858001018666">Large</item>
  5. <item msgid="490158884605093126">Huge</item>
  6. </string-array>

  7. <string-array name="entryvalues_font_size" translatable="false">
  8. <item>0.85</item>
  9. <item>1.0</item>
  10. <item>1.15</item>
  11. <item>1.30</item>
  12. </string-array>
The above configuration is provided to the end user after being loaded using the following code
Packages/app/settings/DisplaySettings. java
 
 
  1. public void readFontSizePreference(ListPreference pref) {
  2. try {
  3. mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
  4. } catch (RemoteException e) {
  5. Log.w(TAG, "Unable to retrieve font size");
  6. }

  7. // mark the appropriate item in the preferences list
  8. int index = floatToIndex(mCurConfig.fontScale);
  9. pref.setValueIndex(index);

  10. // report the current size in the summary text
  11. final Resources res = getResources();
  12. String[] fontSizeNames = res.getStringArray(R.array.entries_font_size);
  13. pref.setSummary(String.format(res.getString(R.string.summary_font_size),
  14. fontSizeNames[index]));
  15. }
At the frameworks layer, a default font size is set for the system. The font scale-down ratio is 1, which is the "normal" font in the corresponding display settings.

Frameworks/base/core/java/android/content/res/Configuration. java

 
 
  1. /**
  2. * Set this object to the system defaults.
  3. */
  4. Public void setToDefaults (){
  5. FontScale = 1; // The default font scale is assigned here.
  6. Mcc = mnc = 0;
  7. Locale = null;
  8. UserSetLocale = false;
  9. Touchscreen = TOUCHSCREEN_UNDEFINED;
  10. Keyboard = KEYBOARD_UNDEFINED;
  11. KeyboardHidden = KEYBOARDHIDDEN_UNDEFINED;
  12. HardKeyboardHidden = HARDKEYBOARDHIDDEN_UNDEFINED;
  13. Navigation = NAVIGATION_UNDEFINED;
  14. NavigationHidden = NAVIGATIONHIDDEN_UNDEFINED;
  15. Orientation = ORIENTATION_UNDEFINED;
  16. ScreenLayout = SCREENLAYOUT_UNDEFINED;
  17. UiMode = UI_MODE_TYPE_UNDEFINED;
  18. ScreenWidthDp = compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
  19. ScreenHeightDp = compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
  20. SmallestScreenWidthDp = compatSmallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
  21. DensityDpi = DENSITY_DPI_UNDEFINED;
  22. Seq = 0;
  23. }



Related Article

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.