ViewCompat.setOnApplyWindowInsetsListener is only called on some devices?

525 views Asked by At

I'm trying to display my app edge-to-edge but results are not even consistent across devices. ViewCompat.setOnApplyWindowInsetsListener is called on Pixel 4a/5 but not on Pixel 3 XL and Essential PH-1, the app just draws behind the status bar when I try to set padding (with or without android:fitsSystemWindow="true"). I suspect it's because of the notch (edge-to-edge doesn't work on Pixel 3 XL and Essential PH-1). I'm also using CoordinatorLayout, DrawerLayout, etc, so there's the whole fitsSystemWindow thing. I can't seem to get it to work no matter what. Watched a couple of Chris Banes' presentations but I'm still clueless.

1

There are 1 answers

1
nsko On BEST ANSWER

Could this problem be related to Display Cutoffs? Pixel 4a/5 have cutoffs whereas Pixel 3 doesn't.

From class WindowInsets.java:482

* Returns the display cutout if there is one.
* Note: the display cutout will already be consumed during dispatch to *View.onApplyWindowInsets, unless the window has requested a WindowManager.LayoutParams.layoutInDisplayCutoutMode other than never or default.
* Returns:
* the display cutout or null if there is none
* See Also:
* DisplayCutout
public DisplayCutout getDisplayCutout() {
    return mDisplayCutout;
}