Troubleshooting Full Expansion Issues in BottomSheetDialogFragment with Rounded Corners

I want to create a fully expanded BottomSheetDialogFragment with top rounded corners, following the technique described in this GitHub comment – https://github.com/material-components/material-components-android/issues/1278#issuecomment-844979762

Before displaying the BottomSheetDialogFragment, the app extends fully to the bottom of the screen.

Before showing BottomSheetDialogFragment

enter image description here


However, when the dialog is shown in its fully expanded state, the bottom bar does not extend as expected. Please refer to the attached screenshots for a visual reference.

When showing BottomSheetDialogFragment

enter image description here


Here’s our code snippet.

RoundedCornerBottomSheetDialogFragment.kt

class RoundedCornerBottomSheetDialogFragment : BottomSheetDialogFragment() {
    private lateinit var binding : RoundedCornerBottomSheetDialogFragmentBinding

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        binding = RoundedCornerBottomSheetDialogFragmentBinding.inflate(inflater, container, false)

        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val bottomSheet : FrameLayout = dialog?.findViewById(com.google.android.material.R.id.design_bottom_sheet)!!

        // Height of the view
        bottomSheet.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT

        // Behavior of the bottom sheet
        val behavior = BottomSheetBehavior.from(bottomSheet)

        behavior.apply {
            state = BottomSheetBehavior.STATE_EXPANDED
        }
    }

    override fun getTheme(): Int {
        return R.style.RoundedCornerBottomSheetDialogFragmentStyle
    }
}

styles.xml

<resources>
    <style name="RoundedCornerBottomSheetDialogFragmentStyle" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/BottomSheet_NoDrawing</item>
    </style>

    <style name="BottomSheet_NoDrawing" parent="Widget.MaterialComponents.BottomSheet">
        <item name="backgroundTint">@android:color/transparent</item>
    </style>
</resources>

rounded_corner_bottom_sheet_dialog_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/rounded_top_corners_background"

    android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 1" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 2" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 3" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 4" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 5" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 6" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 7" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 8" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 9" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 10" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 11" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 12" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 13" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="56dp"
            android:text="Hello 14" />
    </LinearLayout>
</androidx.core.widget.NestedScrollView>

May I know, how I can resolve this issue, to ensure our app remains edge-to-edge?

The complete workable demo can be downloaded from : https://github.com/yccheok/RoundedCornerBottomSheetDialogFragment

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật