Why can't we use a Translucent system bars with and ActionBar

前端 未结 5 557
迷失自我
迷失自我 2020-12-04 06:07

While updating my apps to Kitkat, I just wanted to give them a gorgeous look on KitKat using the Translucent property:

Translucent system bars

5条回答
  •  半阙折子戏
    2020-12-04 06:59

    This works with less lines:

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow(); // in Activity's onCreate() for instance
            w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    

    Would be great if someone could add, how to check, if the translucent navigation is available at all, because the N10 e.g. will have the translucent navigation disabled with Build.VERSION_CODES.KITKAT. Edit: answered in this question: Check if translucent navigation is available

提交回复
热议问题