VladislavAntonyuk / MauiSamples

.NET MAUI Samples
https://vladislavantonyuk.azurewebsites.net/articles?categoryName=.NET%20MAUI/Xamarin
MIT License
742 stars 189 forks source link

Android: Is there any way to allow touching outside the BottomSheet without closing the bottomsheet! Is it possible to behave like standard sheet and not like a modal sheet #404

Open Frizbi22 opened 11 months ago

Frizbi22 commented 11 months ago
   I have tried this but no luck!!

    var bottomSheetDialog = new BottomSheetDialog(Platform.CurrentActivity?.Window?.DecorView.FindViewById(Android.Resource.Id.Content)?.Context ?? throw new InvalidOperationException("Context is null"));
    bottomSheetDialog.SetContentView(bottomSheetContent.ToPlatform(page.Handler?.MauiContext ?? throw new Exception("MauiContext is null")));

    // Allow touches on the underlying page
    bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.NotTouchable);
    bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.DimBehind);
    bottomSheetDialog.Window?.ClearFlags(WindowManagerFlags.NotFocusable);

    // Set the behavior of the bottom sheet
    bottomSheetDialog.Behavior.Hideable = true;
    bottomSheetDialog.Behavior.FitToContents = true;
    bottomSheetDialog.SetCancelable(true);
    bottomSheetDialog.Behavior.HalfExpandedRatio = 0.5f;

    bottomSheetDialog.Show();
    return bottomSheetDialog;

    on iOS is working as intended when using medium or large detents!
VladislavAntonyuk commented 10 months ago

Probably this flag should be false: bottomSheetDialog.Behavior.Hideable

Frizbi22 commented 9 months ago

I have tried that but bottomSheetDialog.Behavior.Hideable is a property that determines whether the bottom sheet is responsive to drag gestures. Sadly i found no solution for it