目前为止只支持4.4以上的版本。

首先需要用到systembartintAndroid沉浸式(设置状态栏颜色)_第1张图片


compile好之后就可以了,直接上代码了


public class BaseActivity extends FragmentActivity {    protected SystemBarTintManager tintManager;    @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        initWindow();    }    @TargetApi(19)    protected void initWindow() {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);            tintManager = new SystemBarTintManager(this);            setStatusBarColor(getResources().getColor(R.color.colorAccent));            tintManager.setStatusBarTintEnabled(true);        }    }    protected void setStatusBarColor(int color) {        if (tintManager != null)            tintManager.setStatusBarTintColor(color);    }    protected void disableSystemBarTint() {            if (tintManager != null)                tintManager.setStatusBarTintEnabled(false);    }}
   
   
   
public class MainActivity extends BaseActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);//        setStatusBarColor(Color.parseColor("#000000"));//        disableSystemBarTint();    }}
你可以直接继承,在BaseActivity里面设置状态栏的颜色,如果你要设置其他的颜色,可以通过
setStatusBarColor()来设置,
disableSystemBarTint();是根据你title的颜色去设置的,希望能帮到你!
   
   
   
   





更多相关文章

  1. 重写Android Log的输出,只在debug的时候输出,release 的版本不输出
  2. android之Notification版本兼容性问题
  3. Android版本28用http请求CLEARTEXT communication to www.xxxxx.
  4. android获取版本信息、屏幕信息和设备编号
  5. android高版本Toast问题
  6. 设置android的布局文件的背景颜色为黑色
  7. Android统一依赖多个不同版本的Support v7包
  8. Android 动态设置颜色

随机推荐

  1. [置顶] 自定义的解压进度条 关于Progress
  2. Windows下搭建Android SDK开发环境
  3. Android模拟用户点击的实现方法
  4. Android 广播机制---BroadCast
  5. 安卓单元测试 - 收藏集 - 掘金
  6. android view中invalidate和postInvalida
  7. Android相册及小小秒表震动(17)
  8. android : px dip
  9. Android最经典的入门手册
  10. 活动的四种启动模式