导航栏3种模式
在安卓系统中,“config_navBarInteractionMode” 是一个特定的配置参数,用于设定安卓设备导航栏的交互模式。
frameworks/base/core/res/res/values/config.xml
<!-- Controls the navigation bar interaction mode:
0: 3 button mode (back, home, overview buttons)
1: 2 button mode (back, home buttons + swipe up for overview)
2: gestures only for back, home and overview -->
- 0 3按键导航 底部有3个按键
- 1 2按键导航 底部有2个按键
- 2 手势导航 底部有一条横线
如下图为三按键模式:
如下图为手势模式
修改设置默认为手势导航模式
diff --git a/frameworks/base/core/res/res/values/config.xml b/frameworks/base/core/res/res/values/config.xml
index bed476cdc0..fc961154b3 100755
--- a/frameworks/base/core/res/res/values/config.xml
+++ b/frameworks/base/core/res/res/values/config.xml
@@ -3235,7 +3235,7 @@
0: 3 button mode (back, home, overview buttons)
1: 2 button mode (back, home buttons + swipe up for overview)
2: gestures only for back, home and overview -->
- <integer name="config_navBarInteractionMode">0</integer>
+ <integer name="config_navBarInteractionMode">2</integer>
<!-- Controls whether the nav bar can move from the bottom to the side in landscape.
Only applies if the device display is not square. -->
控制导航栏显示
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
控制三个按钮的显示: 返回、HOME、Recents
getBackButton().setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
getHomeButton().setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);
控制手势横线的显示可以通过这条语句
getHomeHandle().setVisibility(disableHomeHandle ? View.INVISIBLE : View.VISIBLE);
下面这个修改是隐藏navigationBar的三键与手势横线,前面我们修改的是设置为手势模式,这里虽然隐藏了手势横线的显示,但是手势模式中的左右滑退出的功能是还存在的。
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index d0c0226db9..c3561681ee 100644
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -819,6 +819,8 @@ public class NavigationBarView extends FrameLayout implements
}
}
+ // hide navigationbar
+ disableBack = disableHome = disableRecent = disableHomeHandle = true;
getBackButton().setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
getHomeButton().setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);
作者:帅得不敢出门