Android 两行代码实现修改状态栏与标题栏颜色相同

来源:互联网 发布:手机淘宝搜同款怎么搜 编辑:程序博客网 时间:2024/05/18 13:25

现如今许多app,在设计的时候都是,将标题栏和状态栏使用同一颜色,查询网上很多中设置状态栏的方法,都需要写很多代码;还得进行版本判断,

在项目的build.gradle中声明以下依赖:

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

在你的BaseActivity中(最好是setContentView()被调用之后)添加以下代码:

StatusBarCompat.setStatusBarColor(this, color, lightStatusBar);

通过以上两行代码就可以实现将标题栏和状态栏的颜色设置为同一种颜色;关于使用规则和使用方法,可以查看github和原文。

原文地址:http://blog.csdn.net/maosidiaoxian/article/details/51734895
github : https://github.com/msdx/status-bar-compat

阅读全文
0 0