Android系统开启导航栏NavigationBar(虚拟按键)

tech2026-01-26  10

导航栏NavigationBar

源码部分:

frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); // Allow a system property to override this. Used by the emulator. // See also hasNavigationBar(). String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); if ("1".equals(navBarOverride)) { mHasNavigationBar = false; } else if ("0".equals(navBarOverride)) { mHasNavigationBar = true; }

显示方案:

[1]使用adb命令开启Android手机虚拟按键(导航栏) adb root adb remount adb shell $ getprop qemu.hw.mainkeys #查看值 $ setprop qemu.hw.mainkeys 0 #设置值为0,属性值为1 表示未打开虚拟按键,属性值为0表示一直打开虚拟按键 $ stop $ start [2]修改config.xml文件

设置config_showNavigationBar为true就可以打开系统的虚拟键

framework/base/core/res/res/values/config.xml <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be autodetected from the Configuration. --> <bool name="config_showNavigationBar">true</bool> <!--<bool name="config_supportSystemNavigationKeys">false</bool>-->

一般这种config 文件都会有overlay文件,所以也需要修改对应的device下的overlay文件

device\qcom\msm8953_64\overlay\frameworks\base\core\res\res\values\config.xml <!-- Whether a software navigation bar should be shown. NOTE: in the future this may be autodetected from the Configuration. --> <bool name="config_showNavigationBar">true</bool> <!--<bool name="config_supportSystemNavigationKeys">false</bool>--> [3]添加配置文件

添加qemu.hw.mainkeys=0,也就是修改 androdi系统的system/build.prop

device\qcom\msm8953_64\system.prop qemu.hw.mainkeys=0
最新回复(0)