Android R 如何修改设置中默认显示大小?

方法1:

1.需添加如下log,然后进入到“设置–显示–显示大小”界面 summary 显示为small而不是default,查看对应的ylog“oncreate valuse =”,以确定设备上目前显示的各等级原始数值:

diff --git a/src/com/android/settings/display/ScreenZoomSettings.java b/src/com/android/settings/display/ScreenZoomSettings.java
index ec3999b..22d9f67 100644
--- a/src/com/android/settings/display/ScreenZoomSettings.java
+++ b/src/com/android/settings/display/ScreenZoomSettings.java
@@ -32,7 +32,7 @@ import com.android.settingslib.display.DisplayDensityUtils;

 import java.util.ArrayList;
 import java.util.List;
-
+import java.util.Arrays;
 /**
  * Preference fragment used to control screen zoom.
  */
@@ -45,6 +45,7 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment impleme
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

+        android.util.Log.d("ScreenZoomSettings","oncreate");
         mActivityLayoutResId = R.layout.screen_zoom_activity;

         // This should be replaced once the final preview sample screen is in place.
@@ -69,6 +70,7 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment impleme
             mEntries = density.getEntries();
             mInitialIndex = initialIndex;
             mDefaultDensity = density.getDefaultDensity();
+            android.util.Log.d("ScreenZoomSettings","oncreate valuse = " + Arrays.toString(mValues));
         }
     }

根据各等级对应的数值,可参考如下修改,配置默认的density,并写入数据库,进行验证:

 diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index cdc80fd..cee72cc 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -249,4 +249,8 @@
     0
    
     1
+
+   
+    240
+
 
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/sett
index 8d3c472..10f508f 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2434,6 +2434,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
             loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT,
                     R.integer.def_sleep_timeout);

+            loadStringSetting(stmt, Settings.Secure.DISPLAY_DENSITY_FORCED,
+                    R.string.def_display_density);
             /*
              * IMPORTANT: Do not add any more upgrade steps here as the global,
              * secure, and system settings are no longer stored in a database

注:“def_display_density”>240 只是举例说明

方法2:修改

PRODUCT_PROPERTY_OVERRIDES += ro.sf.lcd_density=204-------这个是修改默认 default的值

你可能感兴趣的:(android,r语言,java)