Translucent status bar in Android

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

I am using the following layout (main_activity.xml)




        
6条回答
  •  春和景丽
    2020-12-17 02:12

    try this:

    add this in your app theme:

    true
    true
    

    Set android:fitsSystemWindows=”true” to root container

    Now in your activity onCreate():

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow();
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }
    

    Updated, Result:

    you can make the snackbar draw on top of screen:

    Snackbar snack = Snackbar.make(parentLayout, str, Snackbar.LENGTH_LONG);
    View view = snack.getView();
    FrameLayout.LayoutParams params =(FrameLayout.LayoutParams)view.getLayoutParams();
    params.gravity = Gravity.TOP;
    view.setLayoutParams(params);
    snack.show();
    

    For more info see here

提交回复
热议问题