How to change the status bar color in Android?

后端 未结 21 2265
旧时难觅i
旧时难觅i 2020-11-21 16:09

First of all it\'s not a duplicate as in How to change the background color of android status bar

How do I change the status bar color which should be same as in nav

21条回答
  •  没有蜡笔的小新
    2020-11-21 16:46

    One more solution:

    final View decorView = w.getDecorView();
    View view = new View(BaseControllerActivity.this);
    final int statusBarHeight = UiUtil.getStatusBarHeight(ContextHolder.get());
    view.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, statusBarHeight));
    view.setBackgroundColor(colorValue);
    ((ViewGroup)decorView).addView(view);
    

提交回复
热议问题