1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Android 9.0 显示系统导航栏(左/右/底部)

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

时间:2018-08-30 10:55:42

相关推荐

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。