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

[BottomSheet] Expanded bottom sheet with `fitToContents=false` is not full screen

Open
#3,018 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**Description:**

Simple bottom sheet that starts `expanded` and has `fitToContents=false`:
```kotlin
class MyBottomSheet : BottomSheetDialogFragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) =
inflater.inflate(R.layout.fragment_second, container, false)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

(dialog as BottomSheetDialog).behavior.apply {
state = BottomSheetBehavior.STATE_EXPANDED
isFitToContents = false
}
}
}
```

will appear flying on top of the screen:

https://user-images.githubusercontent.com/3951580/195555156-25e88b5d-082d-4b7d-a1b8-08e9122d9f8f.mov

**Expected behavior:** Bottom sheet is full-screen, laid out with `match_parent` height

**Source code:** above

**Minimal sample app repro:**
[bottom-sheet.zip](https://github.com/material-components/material-components-android/files/9774922/bottom-sheet.zip)

**Material Library version:** 1.6.1

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 provided minimal sample app and reproduce the expanded BottomSheetDialogFragment behavior using BottomSheetBehavior with fitToContents=false. Trace the layout and expanded-state handling from the sample into the Material bottom-sheet implementation. Done means the expanded sheet is laid out at full-screen, match_parent height rather than floating above the screen.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
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.