现如今许多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