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

[BottomSheetDialog] layout_margin - sheet moves to set margin value when anything in it is interacted with - 1.5.0 and 1.6.0-alpha03

Open
#2,589 0 comments 0 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

The bottomsheet has a top margin of 25dp. When an item is added to the recyclerview within, the bottomsheet jumps down 25dp once. So if the bottom sheet starts GONE, an item is added, it's set to 120dp peekheight. That works fine.

But when any more items are added the sheet jumps back to 95dp (120-25) height. If you drag the sheet up and back down it rests at 120 as it should. But it will jump back to 95 if another item is added. This happens if any of the margin options that include the top (layout_margin, layout_margin_vertical)

It works fine with no margin set.

Device: emulator, and real phone Fold 2.

API: 30

tried on 1.5.0 and 1.6.0 alpha3

XML::

<data>
    <variable
        name="..."
        type="..." />
</data>

<FrameLayout
    android:id="@+id/top_frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="0dp"
        map:uiCompass="true"
        map:uiMapToolbar="true"
        map:uiZoomControls="true"
        tools:context=".MapsActivity"
        tools:layout="@layout/support_simple_spinner_dropdown_item"
        tools:visibility="gone" />

    <androidx.constraintlayout.widget.ConstraintLayout

    </androidx.constraintlayout.widget.ConstraintLayout>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:visibility="invisible">

        <FrameLayout
            android:id="@+id/standard_bottom_sheet"
            style="@style/ModalBottomSheetDialog"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="25dp"
            map:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

            <!-- Bottom sheet contents. -->

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:visibility="visible">

                <com.google.android.material.chip.Chip ...

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/recycler_view"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    map:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                    map:layout_constraintBottom_toBottomOf="parent"
                    map:layout_constraintEnd_toEndOf="parent"
                    map:layout_constraintStart_toStartOf="parent"
                    map:layout_constraintTop_toBottomOf="@id/bottom_sheet_chip" />

            </androidx.constraintlayout.widget.ConstraintLayout>
        </FrameLayout>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:alpha="0"
        android:background="#FFFFFF">

    </Toolbar>

</FrameLayout>

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 by reproducing the issue with BottomSheetBehavior, a 25dp top margin, and RecyclerView items added after the sheet is shown, using the XML layout and versions described. Trace how the sheet measures or positions itself when items are added, and consider the issue done when the configured 120dp peek height remains stable with top-margin variants and the no-margin behavior is unchanged.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.