在Android上更改导航栏图标的颜色 [英] Change navigation bar icon color on Android

查看:270
本文介绍了在Android上更改导航栏图标的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改android上的导航栏.就像下面图像中右侧的'light'变体一样 如 https://www.google所述. co.in/design/spec/layout/structure.html#structure-system-bars .

现在,我可以使用

I need to change the navigation bar on android. Just like the 'light' variant on the right in the image below as given in https://www.google.co.in/design/spec/layout/structure.html#structure-system-bars.

Now, I can change the background of the navigation bar by using

"android:navigationBarColor"

我知道

,但是似乎无法将按钮颜色更改为深色.

but there seems to be no way changing the button color to dark.

任何人都知道如何执行此操作.

Anyone has the idea how to do it.

PS:

在AOSP中研究负责NavigationButtons的类时,我可以找到

While researching in AOSP for the classes responsible for NavigationButtons, I could find NavigationBarView.java, PhoneStatusBar.java, PhoneWindowManager.java, navigation_bar.xml.

我正在考虑为ic_sysbar_recent之类的导航栏按钮获取可绘制对象的引用,并更改其色调.但是这些都是私人的,我无法获得它们的参考.

I was thinking of get reference of the drawable for the navigationbar buttons like ic_sysbar_recent and change their tint. But these are private and I cannot get their reference.

我还看到人们使用xposed库来实现它 L-NAVBAR ,但我不想使用任何外部库.

Also, I have seen people using xposed library to do it L-NAVBAR, but I don't want to use any external library.

推荐答案

如果您使用的是API 27(Android 8.1)或更高版本,则可以在主题中使用以下方法实现:

If you are using API 27 (Android 8.1) or greater, you can achieve it with this in your theme:

<item name="android:windowLightNavigationBar">true</item>

您可以创建一个名为 values-v27 的文件夹,并使用明亮的导航栏和上面的代码放置主题的版本(在styles.xml中),以获取黑暗的导航栏按钮.
这样,Android 8.0或更低版本的用户将获得标准(黑色)导航栏,而Android 8.1或更高版本的用户将获得带有深色按钮的白色导航栏.

You can create a folder called values-v27 and place a version of your theme (in styles.xml) with a light navigation bar and the above code to get dark navigation bar buttons.
This way, users with Android 8.0 or lower will get the standard (black) navigation bar while users with Android 8.1 or greater will get a white navbar with dark buttons.

这篇关于在Android上更改导航栏图标的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆