If I call setOnApplyWindowInsetsListener() then should I have fitsSystemWindows=”true”

My insets listeners didn’t get called.

If there is not fitsSystemWindows="true" applied to the root layout, then the layout won’t dispatch any insets to its children, thus ViewCompat.setOnApplyWindowInsetListener won’t be triggered.

You use ViewCompat.setOnApplyWindowInsetListenerin order to apply insets to some particular view. In the example there was an ImageView and a Toolbar . The requirement was to apply insets (i.e. status bar padding) to the Toolbar, but not to ImageView .

Should I call manually dispatchApplyWindowInsets() ?

You only need to apply dispatchApplyWindowInsets() in your custom ViewGroup . If you have a “materialish” layout, then you do not need it, because those layouts would dispatch insets to their children.

Android enthusiast, Google Certified Android developer, Stackoverflower

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store