Overlapping shadow effect remains on Navigation Drawer's NavigationView

At last, I made it.

The solution is using FLAG_LAYOUT_NO_LIMITS together with FLAG_FULLSCREEN to the android.view.Window object.

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
        | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

This has gotten rid of both of the shadows perfectly.

enter image description here

lcw_gg's comment was very useful clue to manipulating android.view.Window. Special thanks to him.


The accept answer has a problem. Setting flags FLAG_FULL_SCREEN and FLAG_LAYOUT_NO_LIMITS will make the insets of the window to be 0 and content may lay behind the system UIs.

It will work because NavigationView, which is a subclass of ScrimInsetsFrameLayout, listen to onApplyWindowInsets and View.setWillNotDraw to true when window insets are all 0.

You just need to add to your NavigationView this:

app:insetForeground="@null"