Android 9.0 显示系统导航栏(左/右/底部)

Android 9.0 显示系统导航栏(左/右/底部)

显示系统导航栏 一般有:HOME  BACK  最近应用列表 等组成。

先看下效果图:

显示在底部(最常见的做法):

 

显示在右边(平板):

(请忽略导航栏上的按钮重叠在一起的问题:该部分需要到SystemUI中修改,这里不做说明)

显示在左边(车机等物联网设备):

实现导航栏显示的位置:
1.需要修改配置文件
2.修改导航栏的大小(横-高/竖-宽)
源码路径:
/android9.0/frameworks/base/core/res/res/values中的:


1.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>


2.dimens.xml
<!-- Height of the bottom navigation / system bar. -->

<dimen name="navigation_bar_height">93px</dimen>

<!-- Height of the bottom navigation bar in portrait; often the same as @dimen/navigation_bar_height -->

<dimen name="navigation_bar_height_landscape">93px</dimen>

<!-- Width of the navigation bar when it is placed vertically on the screen -->

<dimen name="navigation_bar_width">93px</dimen>

<!-- Height of the bottom navigation / system bar in car mode. -->

<dimen name="navigation_bar_height_car_mode">93px</dimen>

<!-- Height of the bottom navigation bar in portrait; often the same as

         @dimen/navigation_bar_height_car_mode -->

<dimen name="navigation_bar_height_landscape_car_mode">93px</dimen>

<!-- Width of the navigation bar when it is placed vertically on the screen in car mode -->

<dimen name="navigation_bar_width_car_mode">93px</dimen>

 

导航栏区域是由PhoneWindowManager来处理的。
源码路径:
/android9.0/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

由以下3个变量来处理(是否显示和显示的位置)
boolean mHasNavigationBar = false;

boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?

@NavigationBarPosition

int mNavigationBarPosition = NAV_BAR_BOTTOM;

因此我们只需要修改这些属性就可以达到目的。

第一部分:两个布尔值的赋值决定是否显示(mHasNavigationBar)/已经是否允许显示在左右两边(mNavigationBarCanMove)

第二部分:决定显示的位置(底部/左/右)

如下图中:强行打开导航栏


编译验证
终端输入如下指令:

source build/envsetup.sh

lunch ?平台

make framework-res

make services

把编译生成的以下3个文件推到系统对应目录下:
framework-res.apk

services.jar

oat

 

打开终端输入如下指令:

MacBook-Pro ~ % adb root;adb remount;adb push /xxx/out/target/product/xxxx/system/framework/framework-res.apk /xxx/out/target/product/xxxx/system/framework/oat /xxx/out/target/product/xxxx/system/framework/services.jar  /system/framework

 

adbd is already running as root

remount succeeded

/xxx/out/target/product/xxxx/system/framework/framework-res.apk: 1 file pushed, 0 skipped. 5.9 MB/s (28286283 bytes in 4.581s)

/xxx/out/target/product/xxxx/system/framework/oat/: 13 files pushed, 0 skipped. 5.6 MB/s (53523092 bytes in 9.143s)

/xxx/out/target/product/xxxx/system/framework/services.core.jar: 1 file pushed, 0 skipped. 9.2 MB/s (4019568 bytes in 0.419s)

15 files pushed, 0 skipped. 5.6 MB/s (85828943 bytes in 14.571s)

 

MacBook-Pro ~ % adb reboot

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小猿成长

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值