How can we change the background color for android botom dialog to transparent ?
AswinPG opened this issue · 3 comments
AswinPG commented
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 :)
VladislavAntonyuk commented
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.
VladislavAntonyuk commented
I won't add it to sample, but you can find the answer here: https://stackoverflow.com/questions/37104960/bottomsheetdialog-with-transparent-background
AswinPG commented
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);
}
}`