Since in Android API 35+ the Edge-to-edge behavior is enforced, I'm trying to implement it in my app Toolbar. This is my current implementation:
<androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?android:attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" /> To apply the top padding:
final Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle(getString(R.string.app_name)); toolbar.showOverflowMenu(); setSupportActionBar(toolbar); toolbar.setElevation(0); toolbar.setTitle(ctx.getString(R.string.summary)); .... ViewCompat.setOnApplyWindowInsetsListener(toolbar, (v, windowInsets) -> { final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()); v.setPadding(paddingLeft + insets.left, paddingTop + insets.top, paddingRight + insets.right, paddingBottom); // return WindowInsetsCompat.CONSUMED; return ViewCompat.onApplyWindowInsets(v, windowInsets); }); This is what I get: (Partially wrong since the items are not in line)
However, when I hide the menu button, the problem is far more evident:

