更改导航栏颜色,Android [英] Change navigation bar color, Android

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

问题描述

如何在 Lollipop 之前的设备中将导航栏的颜色/透明度从黑色更改为通用颜色(例如状态栏或操作栏的颜色)?

How can I change the color/transparency of the Navigation Bar from black to a generic color in pre-Lollipop devices (e.g. the color of the status bar or of the action bar)?

我可以使用 AppCompat 来实现还是仅适用于 SDK 21?

Can I do it using AppCompat or is it only possible for SDK 21?

推荐答案

您可以在 AppCompat 主题中设置属性 navigationBarColor,或者在原生 v21 中设置 android:navigationBarColor主题.

You can set the attribute navigationBarColor in an AppCompat theme, or android:navigationBarColor in a native v21 theme.

<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
    ...
    <item name="navigationBarColor">#123456</item>
</style>

https://developer.android.com/training/material/theme.html#StatusBar

请注意,这不适用于 Pre-Lollipop 设备,因为此功能需要系统支持,而在 Android 4.4 或更早版本上则不支持.

Note that this does not work on Pre-Lollipop devices, since this feature needs to be supported by the system, which is not the case on Android 4.4 or older.

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

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