GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — BottomSheetBehavior ignores child View heights when calculating position (OPPO ColorOS Android 16) · Issue #5080 · material-components/material-components-android Open DescriptionBottomSheetBehavior does not account for child View heights (including spacers) when calculating its position, causing it to overlap system navigation bar on devices with incorrect WindowInsets values. Expected behaviorWhen a spacer View is added to the bottom of BottomSheet content with a specific height, BottomSheetBehavior should position itself to accommodate that spacer, keeping all content visible above the navigation bar. Actual behaviorBottomSheetBehavior ignores the spacer View height and positions itself based only on WindowInsets values, even when those values are incorrect. Device Information
Root CauseColorOS on Android 16 reports incorrect WindowInsets.bottom value (88px instead of ~720px). While this is a ColorOS bug, BottomSheetBehavior has no fallback mechanism to handle incorrect system values. ReproductionLayout<LinearLayout android:id="@+id/bottomSheetContainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- Content --> <View android:id="@+id/spacer" android:layout_width="match_parent" android:layout_height="0dp" /> </LinearLayout> CodeViewCompat.setOnApplyWindowInsetsListener(bottomSheet) { view, insets -> val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) // Set spacer height to correct value val spacer = view.findViewById<View>(R.id.spacer) val params = spacer.layoutParams params.height = 480 // Correct value spacer.layoutParams = params insets } val behavior = BottomSheetBehavior.from(bottomSheet) // BottomSheet still overlaps navigation bar despite spacer LogsWorkarounds Attempted
Proposed SolutionOption 1: Account for child heightsModify BottomSheetBehavior to include child View heights in position calculation: private fun calculatePosition() { val windowInsets = getWindowInsets() val childHeight = getTotalChildHeight() // Include all children val position = parentHeight - childHeight - windowInsets.bottom // ... } Option 2: Allow manual offset overrideAdd API to manually override WindowInsets: behavior.setNavigationBarOffset(480) // Manual override Option 3: Detect incorrect WindowInsetsAdd validation for suspiciously small WindowInsets values: private fun getNavigationBarInset(): Int { val systemInset = windowInsets.bottom // Validate: navigation bar is typically 48-96dp if (systemInset < 100 && Build.VERSION.SDK_INT >= 35) { // Suspicious value, use fallback return getFallbackNavigationBarHeight() } return systemInset } ImpactThis issue affects:
Related Issues
Additional ContextThe issue does NOT occur on:
This suggests BottomSheetBehavior should be more resilient to incorrect system values. ActivityMetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |