VladislavAntonyuk/MauiSamples

BottomDrawer not working on Android .net-7.0

edgiardina opened this issue · 3 comments

I'm running into two issues trying to get the bottomdrawer example code. First, it seems like Android.Resources.Content.Id doesn't exist, at least not in .net 7.

I've replaced it with Resource.Id.content, but I'm not sure 100% that's correct.

Second, is I am getting an exception with getTheme() at runtime when the bottom sheet is trying to open

image

  Message=Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference```

The first problem is with your namespace. It contains Android which conflicts with "Android.Resources"

The second issue should be resolved automatically as it should get correct view

You were correct. I've renamed my namespace droid to avoid this.

Instead of declaring my bottomsheet content in the Resources as a datatemplate, I tried passing an entire new Page() to the function. It works, but the bottomsheet's height is not correct (too tall), likely because the new page renders after its been passed to the bottom sheet and not before by calling CreateContent(). Is there a way to have a page call CreateContent?

The flow is next:

  1. You init bottom sheet.
  2. Convert MauiPage to Android page by calling ToPlatform
  3. You set content of bottom sheet
  4. You display bottom sheet. Only in this step is the measurement calculated and the content arranged

I recommend you add a scroll view to your MauiPage. Also play with bottom sheet settings. Similar issue #128

the option you need:

bottomSheetDialog.Behavior.FitToContents = true;