美文网首页
StatusBarCompat设置系统状态栏颜色

StatusBarCompat设置系统状态栏颜色

作者: GiottoYLY | 来源:发表于2018-05-04 15:48 被阅读0次

    声明仓库

    确保在你的根项目的build.gradle中对jcenter的声明:

    allprojects{    repositories {        jcenter()    }}

    声明依赖

    在你要使用的module的build.gradle文件中声明以下依赖:

    compile'com.githang:status-bar-compat:0.7'

    代码调用

    最后在你的Activity的setContentView()方法调用之后,调用以下方法即可。

    StatusBarCompat.setStatusBarColor(this, color, lightStatusBar);  (或者是StatusBarCompat.setStatusBarColor(this, color);)

    Fragment中onCreat方法:StatusBarCompat.setStatusBarColor(getActivity(), getActivity().getResources().getColor(R.color.cWhite),lightStatusBar);

    GIT项目地址:https://github.com/msdx/status-bar-compat

    相关文章

      网友评论

          本文标题:StatusBarCompat设置系统状态栏颜色

          本文链接:https://www.haomeiwen.com/subject/fbbodttx.html