Change status bar text color when primaryDark is white

前端 未结 8 1404
自闭症患者
自闭症患者 2021-01-30 06:17

I am trying to reproduce the behaviour of Google Calendar application:

but I have not found a way to change the status text color. If i set the colorPrimaryDark as whit

8条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-30 06:53

    it's very simple:

    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);//  set status text dark
    getWindow().setStatusBarColor(ContextCompat.getColor(BookReaderActivity.this,R.color.white));// set status background white
    

    and vice versa:

    getWindow().setStatusBarColor(ContextCompat.getColor(BookReaderActivity.this, R.color.black));
    View decorView = getWindow().getDecorView(); //set status background black 
    decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); //set status text  light
    

提交回复
热议问题