如何更改状态栏颜色的Andr​​oid API级别19? [英] How to change status bar color in android api level 19?

查看:173
本文介绍了如何更改状态栏颜色的Andr​​oid API级别19?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code。我只能看到动作栏颜色变化。但是,在状态栏不改变

I have the following code. I can only see the action bar color change. But, the status bar does not change.

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- App branding color for the app bar -->
        <item name="colorPrimary">#009688</item>
        <!-- Darker variant for the status bar and contextual app bars -->
        <item name="colorPrimaryDark">#00796B</item>
        <!-- Theme UI controls like checkboxes and text fields -->
        <item name="colorAccent">#536DFE</item>
    </style>

推荐答案

在API级别19,更改状态栏颜色本身不支持。但好消息是奇巧带来半透明UI风格为状态栏和导航栏。

In API level 19, changing the status bar color is not natively supported. But the good thing is that Kitkat brought Translucent UI styling for both the status bar and navigation bar.

有一个非常好的库它可以让你的着色系统酒吧与任何颜色或可绘制你想

There is a very nice library which lets you tint the system bars with either colors or drawables you want.

如何使用

第1步 此添加到Android的Studio中的build.grade。

Step 1 Add this to your build.grade in Android Studio.

dependencies {
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
}

第2步

请设置安卓windowTranslucentNavigation 安卓windowTranslucentStatus 主题属性或将 FLAG_TRANSLUCENT_NAVIGATION FLAG_TRANSLUCENT_STATUS 标记在code本活动的窗口。

Please set android:windowTranslucentNavigation or android:windowTranslucentStatus theme attributes to trueor set the FLAG_TRANSLUCENT_NAVIGATION or FLAG_TRANSLUCENT_STATUS flags to your Activity window in code.

第3步

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SystemBarTintManager tintManager = new SystemBarTintManager(this);

    tintManager.setStatusBarTintEnabled(true);

    tintManager.setNavigationBarTintEnabled(true);
}

有大量的自定义,你可以使用这个库去做的。只需通过图书馆网页我给了一个链接,或检查示例应用程序

There are lots of customizations that you can do with this library. Just go through the library page I gave a link to or check the sample app.

这篇关于如何更改状态栏颜色的Andr​​oid API级别19?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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