Android - Making activity full screen with status bar on top of it

后端 未结 8 1393
北恋
北恋 2020-12-12 19:30

I want to make my activity full screen with status bar on top of it like this picture:

I have used this code in manifest inside activity

相关标签:
8条回答
  • 2020-12-12 20:02

    If you dont want your "Translucent navigation" transparent, here is the code to just make transparent the status bar

    In your theme:

        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowTranslucentStatus">true</item>
    

    In your activity onCreate:

    Window window = getWindow();
    WindowManager.LayoutParams winParams = window.getAttributes();
    winParams.flags &= ~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    window.setAttributes(winParams);
    window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    
    0 讨论(0)
  • 2020-12-12 20:02

    In Kotlin just use following code in your activity, also add android:fitsSystemWindows="true" in your parent view of activity.xml layout file. This will also show content over navigation bar too, provided you declared full screen style in your style.xml

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
         window.setFlags(
                WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
            )
        }
    
    0 讨论(0)
提交回复
热议问题