I'm trying to have an immersive view implemented for a dialogfragment, and not having an expected behavior happening.
Here's part of my code in onViewCreated(view, Bundle savedInstanceState)
getDialog().getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
WindowManager.LayoutParams lp = getDialog().getWindow().getAttributes();
lp.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getDialog().getWindow().setAttributes(lp);
view.setPaddings(0,topPadding,0,bottomPadding);
When I run the above code, from the debugger it seems like it's setting the padding for the view to desired value, but from the app itself it never gets applied. it gets 0 all around.
The reason that I added setPaddings is that when onTap later i wanted to hide system bars by using
windowInsetsController.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
and remove padding through animation.
This being said, from the first part of the code, getDialog().getWindow().setAttributes(lp);
if this is called alone, the fragment it successfully fills entire screen, below status bar and navigation bar.
view.setPaddings(0, topPadding, 0, bottomPadding); if this is called alone, the fragment successfully gets padding top and bottom.
however, if i call them both like I've done in the first snippet of the code, only getDialog().getWindow().setAttributes(lp); takes effect and the setPadding does not. it always gets 0 paddings all around.
What am I doing wrong? is there something that I am missing that needs to be called?
Thanks in advance! any lead or advices would be appreciated.