Android 12 点大屏时,底下导航栏会变成显示一个任务栏,现象如下图:
如果想要屏蔽底下任务栏显示,可以修改packages/apps/Launcher3/src/com/android/launcher3/config/中的ENABLE_TASKBAR的初始值为false即可。
-
public static final BooleanFlag ENABLE_TASKBAR = getDebugFlag(
-
- "ENABLE_TASKBAR", true, "Allows a system Taskbar to be shown on larger devices.");
-
+ "ENABLE_TASKBAR", false, "Allows a system Taskbar to be shown on larger devices.");
上面修改以后,底下任务栏就没有了,但是这个时候导航栏也是没有的。
跟踪代码发现,如果屏幕的(最小边长度*160/dpi值)< 600,就会判断为设备是平板设备。这个时候SystemUI会移除导航栏显示任务栏,SystemUI中 计算设备是否为平板设备函数为\frameworks\base\packages\SystemUI\shared\src\com\android\systemui\shared\recents\utilities\中的public static boolean isTablet(Context context)
-
public static boolean isTablet(Context context) {
-
final WindowManager windowManager = ();
-
final Rect bounds = ().getBounds();
-
-
float smallestWidth = dpiFromPx(((), ()),
-
().getConfiguration().densityDpi);
-
return smallestWidth >= TABLET_MIN_DPS;
-
}
函数中TABLET_MIN_DPS为600
frameworks\base\packages\SystemUI\src\com\android\systemui\navigationbar\中的函数initializeTaskbarIfNecessary判断设备为平板以后,会调用removeNavigationBar(());移除导航栏显示。
-
/** @return {@code true} if taskbar is enabled, false otherwise */
-
private boolean initializeTaskbarIfNecessary() {
-
if (mIsTablet) {
-
// Remove navigation bar when taskbar is showing
-
removeNavigationBar(());
-
(());
-
} else {
-
();
-
}
-
return mIsTablet;
-
}
这个时候,如果要显示导航栏,把上面的isTablet函数返回false就可以显示了。
-
--- a/frameworks/base/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/
-
+++ b/frameworks/base/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/
-
@@ -127,7 +127,7 @@ public class Utilities {
-
-
float smallestWidth = dpiFromPx(((), ()),
-
().getConfiguration().densityDpi);
-
- return smallestWidth >= TABLET_MIN_DPS;
-
+ return false;//smallestWidth >= TABLET_MIN_DPS;
-
}
-
-
public static float dpiFromPx(float size, int densityDpi) {
补充:如果修改后导航栏显示不见了,应该是系统的dpi有关,如果是1920x1080的屏dpi小于240,就会出现这个问题,这个时候导航栏应该是跑到边上去了。可以尝试如下修改:
-
--- a/frameworks/base/core/res/res/values/
-
+++ b/frameworks/base/core/res/res/values/
-
@@ -3511,7 +3511,7 @@
-
-
<!-- Controls whether the nav bar can move from the bottom to the side in landscape.
-
Only applies if the device display is not square. -->
-
- <bool name="config_navBarCanMove">true</bool>
-
+ <bool name="config_navBarCanMove">false</bool>
-
--- a/frameworks/base/packages/SystemUI/res/values-sw900dp/
-
+++ b/frameworks/base/packages/SystemUI/res/values-sw900dp/
-
@@ -19,6 +19,6 @@
-
<resources>
-
-
<!-- Nav bar button default ordering/layout -->
-
- <string name="config_navBarLayout" translatable="false">back,home,left;space;right,recent</string>
-
+ <string name="config_navBarLayout" translatable="false">left;volume_sub,back,home,recent,volume_add,screenshot;right</string>