Translucent status bar in Android

后端 未结 6 2054
猫巷女王i
猫巷女王i 2020-12-17 01:17

I am using the following layout (main_activity.xml)




        
6条回答
  •  悲哀的现实
    2020-12-17 02:00

    Add these two lines in the onCreate of the activity that you want its layout status bar to be transparent

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    

    No need to change your app theme or xml layout. In doing this your bar doesn't have to be transparent throughout your whole app if you don't want to.

提交回复
热议问题