3

I've designed my bottom sheet like this

<style name="ShapeAppearanceOverlay.BottomSheet" parent="">
    <item name="cornerSize">30dp</item>
    <item name="cornerFamily">rounded</item>
</style>

And it works fine my bottom sheet comes up with 30dp corner radius, however if I push slide up on my bottom sheet the corner flattens out, How can I prevent this from happening?

enter image description here enter image description here

Rahul Pawar
  • 403
  • 3
  • 13
  • Did your try to setStyle in bottom sheet onCreate? – Amin Jun 23 '21 at 00:45
  • I actually used shapeAppearanceLargeComponenet theme attribute to have this style throughout my app https://bryanherbst.com/2020/05/04/bottom-sheet-corners/ from this guide. – Rahul Pawar Jun 23 '21 at 11:44

2 Answers2

2

I am not sure, if you have already fixed this issue but I found here a solution to prevent sharp corner when its expanded. Her is the link: https://github.com/material-components/material-components-android/issues/1278#issuecomment-844979762

Avoid using shape shapeAppearanceOverlay and add into your layout which is used for bottomSheetDialogFragment, a drawable like below ->

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:topLeftRadius="24dp"
        android:topRightRadius="24dp" />
    <solid android:color="@color/light_white_dark_grey_02" />
</shape>

and for the style use this:

<style name="BottomSheetDialog" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/BottomSheet</item>
    <item name="android:colorBackground">@color/white</item>
</style>
<style name="BottomSheet" parent="Widget.MaterialComponents.BottomSheet.Modal">
    <item name="backgroundTint">@android:color/transparent</item>
</style>

It worked for me but I recommend have a look into that link that I shared above ;)

Olcay Sönmez
  • 602
  • 1
  • 7
  • 16
1

Use this style in your bottom sheet for transparent background

    <style name="BottomSheetMainStyle" parent="ThemeOverlay.MaterialComponents.Light.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/Widget.Test.BottomSheet.Modal</item>
    </style>

    <style name="Widget.Test.BottomSheet.Modal" parent="Widget.MaterialComponents.BottomSheet.Modal">
        <item name="backgroundTint">@android:color/transparent</item>
    </style>
Android Geek
  • 8,956
  • 2
  • 21
  • 35