material-components / material-components/material-components-android
[BottomSheet] Empty space being created for something I've set to fill the space inside BottomSheet
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:** Full description of issue here
I just wanted to have some scrollable content in BottomSheetDialogFragment.
**Expected behavior:** Screenshots and/or description of expected behavior
Fill the space of the bottom sheet, having the TextView at the top of the content.
What happens instead is that it got empty space above the TextView.

**Source code:** The code snippet which is causing this issue
```
```
```
class ModalBottomSheet : BottomSheetDialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(R.layout.modal_bottom_sheet_content, container, false)
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog: BottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
dialog.behavior.saveFlags = BottomSheetBehavior.SAVE_ALL
return dialog
}
companion object {
const val TAG = "ModalBottomSheet"
}
}
```
```
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
findViewById(R.id.button).setOnClickListener {
val modalBottomSheet = ModalBottomSheet()
modalBottomSheet.show(supportFragmentManager, ModalBottomSheet.TAG)
}
}
}
```
**Android API version:** Android API version here
35
**Material Library version:** Material Android Library version you are using here (e.g., 1.1.0-alpha07)
1.13.0-alpha07
**Device:** Device on which the bug was encountered here
Pixel 6.
[My Application.zip](https://github.com/user-attachments/files/17440376/My.Application.zip)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided modal_bottom_sheet_content layout and ModalBottomSheet class on API 35 using Material 1.13.0-alpha07. Start by running the supplied sample with the BottomSheetDialogFragment and inspect the resulting layout around the TextView. Done means the bottom sheet fills as expected without unexplained empty space above the content, with regression coverage if the project provides a relevant test location.
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
- 35/100