当前位置: 代码迷 >> Android >> Android改变状态栏颜色领航不变
  详细解决方案

Android改变状态栏颜色领航不变

热度:67   发布时间:2016-04-27 23:55:29.0
Android改变状态栏颜色导航不变

(1)

在你的activity oncreate 中添加

 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            SystemBarTintManager tintManager = new SystemBarTintManager(this);        tintManager.setStatusBarTintEnabled(true);        tintManager.setStatusBarTintResource(R.color.actionbar_bg);           }(2) 设置头部边距     contentView = getWindow().getDecorView().findViewById(android.R.id.content);     contentView.setPadding(0,getStatusBarHeight(),0,0);     (3)
 public int getStatusBarHeight() {  int result = 0;  int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");  if (resourceId > 0) {      result = getResources().getDimensionPixelSize(resourceId);  }  return result;}
 

版权声明:本文为博主原创文章,未经博主允许不得转载。

  相关解决方案