Why Theme Of BottomSheetDialog Not Working if Expanded?

32 Views Asked by At

My Theme Resource not working when BottomSheetDialog is Expanded state?

@Override
protected void onStart() {
    super.onStart();
    behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}

When calling on My Activity, Theme resources is not working?

val dialog = BottomSheetDialog(this,
    R.style.ThemeOverlay_MaterialComponents_RoundShapeBottomSheetDialog)

When Expanded mode, background bottomsheet back to default, Why this?

1

There are 1 best solutions below

1
ibraheem lubbad On

Customize the BottomSheetDialog Background,you can create a custom style for the BottomSheetDialog that modifies the default background.

 <!-- styles.xml -->
<style name="CustomBottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
    <item name="android:background">@color/your_custom_background_color</item>
    <item name="bottomSheetDialogCornerRadius">0dp</item>
</style>

Then apply this theme when creating your BottomSheetDialog:

val dialog = BottomSheetDialog(this, R.style.CustomBottomSheetDialogTheme);