Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tabasavr opened this issue Jul 17, 2024 · 0 comments
Labels

Comments

@tabasavr
Copy link

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:

<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/bs"
        android:layout_width="match_parent"
        android:layout_height="800dp"
        android:background="#1B5E20"
        android:layout_gravity="bottom"
        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
        >
    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

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

@tabasavr tabasavr added the bug label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant