长沙网站制作哪家好,发泡机 东莞网站建设,展馆,网站qq联系代码种类
Android10 默认的系统导航有三种#xff1a; 1.两个按钮的 2.三个按钮的 3.手势 它们分别对应三个包名 frameworks/base/packages/overlays/NavigationBarMode2ButtonOverlay frameworks/base/packages/overlays/NavigationBarMode3ButtonOverlay frameworks/base/packa…种类
Android10 默认的系统导航有三种 1.两个按钮的 2.三个按钮的 3.手势 它们分别对应三个包名 frameworks/base/packages/overlays/NavigationBarMode2ButtonOverlay frameworks/base/packages/overlays/NavigationBarMode3ButtonOverlay frameworks/base/packages/overlays/NavigationBarModeGesturalOverlay 在设置里切换导航模式的时候会执行SystemNavigationGestureSettings.java的如下方法 static void setCurrentSystemNavigationMode(Context context, IOverlayManager overlayManager,String key) {switch (key) {case KEY_SYSTEM_NAV_GESTURAL:int sensitivity getBackSensitivity(context, overlayManager);setNavBarInteractionMode(overlayManager, BACK_GESTURE_INSET_OVERLAYS[sensitivity]);break;case KEY_SYSTEM_NAV_2BUTTONS:setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);break;case KEY_SYSTEM_NAV_3BUTTONS:setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);break;}}private static void setNavBarInteractionMode(IOverlayManager overlayManager,String overlayPackage) {try {overlayManager.setEnabledExclusiveInCategory(overlayPackage, USER_CURRENT);} catch (RemoteException e) {throw e.rethrowFromSystemServer();}}
-----------------------------------------------------------------------------------String NAV_BAR_MODE_3BUTTON_OVERLAY com.android.internal.systemui.navbar.threebutton;String NAV_BAR_MODE_2BUTTON_OVERLAY com.android.internal.systemui.navbar.twobutton;String NAV_BAR_MODE_GESTURAL_OVERLAY com.android.internal.systemui.navbar.gestural;-----------------------------------------------------------------------------------
根据手势加载不同的overlayPackage也就是上面的三个包名
配置文件
这三个包都有对应的配置文件 config
这个文件配置了config_navBarInteractionMode即该模式编号。
如下是3按钮导航的config.xml文件
resources!-- 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 --integer nameconfig_navBarInteractionMode0/integer
/resources
strings
就是配置字符串这个没什么好说的
dimens
这里配置了导航栏的宽高之类的如下是手势导航的dimens.xml
resources!-- Height of the bottom navigation / system bar. --dimen namenavigation_bar_height16dp/dimen!-- Height of the bottom navigation bar in portrait; often the same as dimen/navigation_bar_height --dimen namenavigation_bar_height_landscape16dp/dimen!-- Width of the navigation bar when it is placed vertically on the screen --dimen namenavigation_bar_width16dp/dimen!-- Height of the bottom navigation / system bar. --dimen namenavigation_bar_frame_height48dp/dimen!-- The height of the bottom navigation gesture area. --dimen namenavigation_bar_gesture_height32dp/dimen
/resources
当你选择了手势导航时系统就会从这里获取资源。
如果你想配置三导航的宽高也可以在三导航的 overlayPackage 下添加dimens文件。
没有在对应的overlayPackage下添加dimens文件的话系统默认会从frameworks/base/core/res/res/values/dimens.xml中获取如下 !-- Height of the bottom navigation / system bar. --dimen namenavigation_bar_height48dp/dimen!-- Height of the bottom navigation bar in portrait; often the same as dimen/navigation_bar_height --dimen namenavigation_bar_height_landscape48dp/dimen!-- Width of the navigation bar when it is placed vertically on the screen --dimen namenavigation_bar_width48dp/dimen!-- Height of the bottom navigation bar frame; this is different than navigation_bar_heightwhere that is the height reported to all the other windows to resize themselves around thenavigation bar window but navigation_bar_frame_height is reported to SystemUI navigationbar views window --dimen namenavigation_bar_frame_heightdimen/navigation_bar_height/dimen!-- Height of the bottom navigation bar frame in landscape --dimen namenavigation_bar_frame_height_landscapedimen/navigation_bar_frame_height/dimen!-- The height of the navigation gesture area if the gesture is starting from the bottom. --dimen namenavigation_bar_gesture_heightdimen/navigation_bar_frame_height/dimen BUG
前提源码设置的默认导航模式其实是三按钮导航我的代码设置的默认导航模式是手势导航
顺带一提默认系统导航模式在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 --integer nameconfig_navBarInteractionMode0/integer
遇到过两个bug一开始是设置大号字体且设置系统导航为三按钮导航后重启。
这个bug一开始我是将frameworks/base/core/res/res/values/dimens.xml的navigation_bar_height改回48dp之前改为了16dp设置大号字体且设置系统导航为三按钮导航后重启问题完美解决至少我是这么以为的。
然后恢复出厂设置第一次开机默认是手势导航然后高为48dp应该为16dp的导航栏空了一大块整个人都不好了然后又把frameworks/base/core/res/res/values/dimens.xml的值改回了16dp检查了frameworks/base/packages/overlays/NavigationBarModeGesturalOverlay的配置确实16dp也没什么问题但就是不起效至今原因不明。
改动了很多值测试都没成功没办法又将代码恢复了最初的设置将48dp改回了16dp然后百度一下大神还是很多的。
终于试了很多种方法后找出了一种有用的 大神原文
【精选】Android 12默认手势导航及bug修复_ro.boot.vendor.overlay.theme_地球边的博客-CSDN博客
大神分析的原因我没看懂但是方法确实有效。
搜索过程中遇到另一篇没看明白的文章虽然没试过里面的方法但也贴在这记录一下
记录修改系统默认导航模式_Only_Studio的博客-CSDN博客