Hi, I’d like to add safe area padding for edge to edge android phones, right now it looks like this.
Please notice the white, barely visible status bar on top and gesture navigation crossing the main buttons. If I add in mainActivity.java the system padding by detecting the insets
public class MainActivity extends BridgeActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// Enable Edge-to-Edge mode
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
EdgeToEdge.enable(this);
super.onCreate(savedInstanceState);
// Handle safe area insets dynamically
ViewCompat.setOnApplyWindowInsetsListener(
findViewById(android.R.id.content), // Root view of the activity
(v, windowInsets) -> {
// Get insets for gesture navigation and system bars
Insets gestureInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemGestures());
Insets systemInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
// Apply padding dynamically (only TOP and BOTTOM)
v.setPadding(
0, // No left padding
systemInsets.top, // Top padding (status bar)
0, // No right padding
gestureInsets.bottom // Bottom padding (gesture navigation bar)
);
// Consume the insets so they aren't passed further
return WindowInsetsCompat.CONSUMED;
}
);
}
}
then I have issues with the overlay in general since capacitor uses webview, it adds correct padding but doesn’t respect the coloring nor dark mode/ light mode switch … I know about the safe area capacitor plugin but it adds such huge padding to both ios and android and to android phones that don’t even need it (that are not edge to edge). Maybe I configured it incorrectly, how do u guys handle edge to edge?
Thank you
2 posts - 1 participant