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

1.需添加如下log,然后进入到“设置–显示–显示大小”界面,查看对应的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 @@
     <integer name="def_navigation_bar_config">0</integer>
     <!-- Default for Settings.System.NAVIGATION_BAR_SHOW -->
     <integer name="def_navigation_bar_show">1</integer>
+
+    <!-- Default for Settings.Secure.DISPLAY_DENSITY_FORCED -->
+    <string name="def_display_density">240</string>
+
 </resources>
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
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值