Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android BottomSheetDialogFragment has color behind rounded corners

I'm using BottomSheetDialogFragment and I'm rounding the corners of top right/left and it's working properly but I noticed that behind the rounded corners, it's not transparent and it's very annoying.

It's noticeable in the below screenshot:

enter image description here

How do I make them transparent?

like image 377
Vahid Amiri Avatar asked Jan 08 '19 13:01

Vahid Amiri


1 Answers

Create custom style like below.

 <style name="AppBottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/AppModalStyle</item>
    </style>

    <style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal">
        <item name="android:background">@drawable/rounded_corner_top_only</item>
    </style>

then override this method in the custom fragment.

 @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //bottom sheet round corners can be obtained but the while background appears to remove that we need to add this.
        setStyle(DialogFragment.STYLE_NO_FRAME,R.style.AppBottomSheetDialogTheme);
    }

This is working with me hopefully it will work with you.

like image 135
Ejaz Ahmad Avatar answered Oct 10 '22 10:10

Ejaz Ahmad