StandardBottomSheet based on ConstraintLayout doesn't fill screen width

27 Views Asked by At

I would like my StandartBottomSheet view to fill the screen size. However, when I use ConstraintLayout as the container, the view has some horizontal paddings. In case of using LinearLayout it works fine.

My ConstaintLayout:

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/geometryDetailsContainer"
            style="@style/Widget.Material3.BottomSheet"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingHorizontal="@dimen/default_margin_one_and_half"
            android:paddingBottom="@dimen/default_margin"
            app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
            tools:ignore="ContentDescription">

Width is setting programmticaly like this:

        BottomSheetBehavior.from(binding.geometryDetailsContainer).apply {
            isShouldRemoveExpandedCorners = false
            state = STATE_HIDDEN
            skipCollapsed = false
            maxWidth = resources.displayMetrics.widthPixels
            addBottomSheetCallback(createBottomSheetCallback())
        }

Example of StandartBottomSheet which works fine:

        <LinearLayout
            android:id="@+id/creatingModeBottomContainer"
            style="@style/Widget.Material3.BottomSheet"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorSurfaceContainerHigh"
            android:orientation="vertical"
            android:paddingHorizontal="@dimen/default_margin_one_and_half"
            app:behavior_peekHeight="@dimen/d40"
            app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
            >
0

There are 0 best solutions below