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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user