material-components / material-components/material-components-android
[BottomSheet] Going from STATE_HIDDEN to STATE_COLLAPSED makes strange animation
@hunterstich ci sta già lavorando.
Dal 10/2/2025.
- Lingua principale
- Java
- Stelle
- 17.4k
- Fork
- 3.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Description:
In simple apps, calling bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED when it is STATE_HIDDEN starts the animation from the bottom of the screen, and eases up into the peek height.
For some reason, in my fork of UAMP, when showing the bottom sheet for the first time by setting the state to collapsed from hidden, the animation starts at about 25% of the way down from the top of the screen (more than half expanded) and within several milliseconds rests at STATE_SETTLED, creating a jarring visual experience.
To reproduce the error, in the sample app, click a card to start the audio player and show the bottom sheet. This only happens the first time a card is clicked after a cold startup.
Expected behavior: Bottom sheet appears in an easing animation animating upwards from the bottom of the screen until it reaches its peek height. What actually happens: bottom sheet appears more than half expanded and animates downwards until it reaches its peek height.
Source code:
private fun showBottomSheetIfNotVisible() {
if (!bottomSheetIsVisible) {
bottomSheetIsVisible = true
behavior.state = BottomSheetBehavior.STATE_COLLAPSED
val params = fragmentContainer.layoutParams as ConstraintLayout.LayoutParams
params.bottomMargin = resources.getDimension(R.dimen.bottomsheet_header_height).toInt()
fragmentContainer.layoutParams = params
}
}
Minimal sample app repro: https://github.com/shmueldabomb441/BottomSheetErrorReportingReproduction (Note: there are a few classes related to the media player and unrelated to the bottom sheet error - I tried to cut away as much as I could while retaining the bug; as far as I can tell, all of the relevant code is in MainActivity.)
Android API version: 32
Material Library version: 1.8.0-alpha01
Device: OnePlus 8T
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.