VladislavAntonyuk/MauiSamples

How can we change the background color for android botom dialog to transparent ?

AswinPG opened this issue · 3 comments

Is it possible to change the background of the bottom sheet to transparent so that we can style the sheet with maui controls... (eg - Corner radius with Border). Thanks :)

I suggest you use CommunityToolkit.MAUI Popup control.

It supports Color Transparent.

If you still want use BottomSheet, I need to see how to implement it.

Thanks @VladislavAntonyuk I was able to make it transparent.

    `public class CustomBottomSheet : BottomSheetDialogFragment
{
    IView mauiView;
    public CustomBottomSheet(IView mauiView)
    {
        this.mauiView = mauiView;
    }
    public override Dialog OnCreateDialog(Bundle savedInstanceState)
    {
        return base.OnCreateDialog(savedInstanceState);
    }
    public override void SetupDialog(Dialog dialog, int style)
    {

        var page = Shell.Current.CurrentPage;
        dialog.SetContentView(mauiView.ToPlatform(page.Handler?.MauiContext ?? throw new Exception("MauiContext is null")));


        FrameLayout frameLayout = (FrameLayout)dialog.Window.FindViewById(Resource.Id.design_bottom_sheet);
        

        //frameLayout.SetPadding(40, 40, 40, 40);
        frameLayout.SetBackgroundResource(Resource.Color.Transparent);
        frameLayout.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
        frameLayout.BackgroundTintMode = PorterDuff.Mode.Clear;
        frameLayout.BackgroundTintList = ColorStateList.ValueOf(Color.Transparent);
        frameLayout.SetBackgroundColor(Color.Transparent);

        base.SetupDialog(dialog, style);
    }
}`