Fix Android sheets opening at ~10px height

OnLayoutChangeListener only fires on future layout changes, but
dialog.show() triggers the initial content layout synchronously
before the listener is registered. The sheet was stuck at the tiny
halfExpandedRatio computed from the pre-layout content height (0).

After registering the listener, do an immediate updateLayout() if
the content view already has a nonzero height, so we pick up the
real dimensions.

https://claude.ai/code/session_01Rp7ef1h3fKh6fhStcjqLJ5
This commit is contained in:
Claude
2026-03-01 08:33:00 +00:00
committed by Samuel Newman
parent 5a122230a7
commit 132c46817f
@@ -335,6 +335,12 @@ class BottomSheetView(
contentView.addOnLayoutChangeListener(listener)
this.contentLayoutListener = listener
this.observedContentView = contentView
// The listener only fires on future changes. If content already laid out
// (e.g. dialog.show() triggered layout synchronously), pick up that height now.
if (contentView.height > 0) {
updateLayout()
}
}
private fun stopObservingContentHeight() {