Change status bar text color when primaryDark is white

前端 未结 8 1278
自闭症患者
自闭症患者 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:44

    Try this once.

    In your activity onCreate() method, paste the following code.

    try {
            if (android.os.Build.VERSION.SDK_INT >= 21) {
                    Window window = getWindow();
                    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                    window.setStatusBarColor(ContextCompat.getColor(this, R.color.color_red));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
    

    Note: color_red - is the status bar colour.

提交回复
热议问题