[BottomSheetDialog] AbstractComposeView
can't be inserted a layout file used to a BottomSheetDialog
.
#4207
Labels
AbstractComposeView
can't be inserted a layout file used to a BottomSheetDialog
.
#4207
Description:
BottomSheetDialog#setContentView(R.layout.earn_more_view)
.ComposeEarnMoreView
who extends fromAbstractComposeView
, and Of course, the@Composable override fun Content()
was implemented byComposable
functions.And the main log looks like below:
Expected behavior: My app won't crash and the layout file should be shown in the
BottomSheetDailog
.Source code:
BottomSheetDialog
or its parentAppCompatDialog
or its delegateAppCompatDelegateImpl
has no LifecycleOwner.If we check the source code of
androidx.activity.ComponentDialog
, which implementsLifecycleOwner
and calledwindow!!.decorView.setViewTreeLifecycleOwner(this)
whenadd/setContentView
.But
BottomSheetDialog/AppCompatDialog/AppCompatDelegateImpl
didn't.Minimal sample app repro:
Android API version: Android 10
Material Library version:
com.google.android.material:material:1.9.0~1.12.0
Device: Huawei Mate 50
Solution:: I found this issue around May, 2023. I thought google team would fix this soon but actually they didn't. So I create an Issue for it to see if I could push google team to fix it inside the material library.
I had a solution like below, hoping it could inspire you guys somehow. Also I could create a PR like the solution below or create a PR inside
AppCompatDelegateImpl
. Tell me what you think.The text was updated successfully, but these errors were encountered: