I’ve adapted my activity to respect insets (system bars) using the common suggested approach (sharing for reference):
ViewCompat.setOnApplyWindowInsetsListener(root, new OnApplyWindowInsetsListener() {
@androidx.annotation.NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@androidx.annotation.NonNull View view, @androidx.annotation.NonNull WindowInsetsCompat insets) {
// Apply the insets (e.g., padding, margin)
paddingsSum = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top + insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom;
view.setPadding(
view.getPaddingLeft(),
insets.getInsets(WindowInsetsCompat.Type.systemBars()).top,
view.getPaddingRight(),
insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom
);
// Return the insets to indicate they're consumed
return insets;
}
});
surely it works, as you can see that on the 1st (left) screenshot the system bars are fully visible:
Now pay attention to the 2nd (right) screenshot, where I’m simply showing an interstitial ad from Google AdMob. For some reason it’s not respecting the insets of the parent Activity. Do you know how can I force Google AdMob interstitial ads to respect the insets (status bar, for example)?
It’s not visible on the screenshot, but on the real device, there is a notch, which covers part of the ad.
2