material-components / material-components/material-components-android

[BottomSheet] Incorrect position when bottom sheet's default layout position is not at the top of parent

Open
#4,228 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Description:**
When bottom sheet would get laid out not at the top of parent view it gets positioned too low. In the example I'm using fixed height that's smaller than screen height and `layout_gravity="bottom"` to achieve this effect. Dragging the sheet fixes its position, but calling `requestLayout` will move it to wrong place again.

**Expected behavior:**
Bottom sheet position is correct and doesn't change when calling `requestLayout()`.

**Source code:**
```


```

**Minimal sample app repro:** https://github.com/tabasavr/BottomSheet-layout-position-bug
This app is also set up to call `requestLayout()` when bottom sheet is clicked. Height used works for Pixel 8 emulator, it might need to be adjusted for other devices

**Android API version:** 21, 34, probably all of them

**Material Library version:** 1.13.0-alpha04, 1.12.0

**Device:** Emulators API 21 and 34

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked minimal sample app and the BottomSheetBehavior layout handling; reproduce the issue by clicking the sheet to trigger requestLayout() and compare its initial and updated positions. Done means the bottom sheet remains correctly positioned after requestLayout() with the sample layout across the reported API versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.