在项目的build.gradle
中声明以下依赖:
compile 'com.githang:status-bar-compat:latest.integration'
在你的Activity中(最好是setContentView()
被调用之后)添加以下代码:
StatusBarCompat.setStatusBarColor(this, color, lightStatusBar);
不用考虑版本,不用考虑fitsSystemWindows
问题,不用考虑状态栏被设置成白色后看不到系统状态的问题,并且兼容MIUI及Flyme。