https://kotlinlang.org logo
#compose
Title
# compose
z

Zach Klippenstein (he/him) [MOD]

05/18/2020, 3:53 PM
I've been using
OwnerAmbient
to get access to the root View for inflating nested Android views further down in the composition. The inflation is being done by another library, so I can't use the
AndroidView(Int)
composable. However,
OwnerAmbient
is deprecated. Is there (or will there be) another API for getting access to the View hosting a composition?
a

Andrey Kulikov

05/18/2020, 4:50 PM
cant you use another overload?
AndroidView(View)
z

Zach Klippenstein (he/him) [MOD]

05/18/2020, 4:51 PM
Yes, I am using that one but I have to inflate the view first, to pass to that function.
So basically I’ve got this:
Copy code
val context = ContextAmbient.current
val rootView = OwnerAmbient.current.view
val childView = remember { LayoutInflater.from(context).inflate(R.layout.foo, rootView, …) }
AndroidView(childView)
Except that inflation code is actually abstracted away by a different library, I just pass in the context and the parent view.
a

Andrey Kulikov

05/18/2020, 5:57 PM
could you please file a bug with this use case?
👍 1
cc @Mihai Popa
z

Zach Klippenstein (he/him) [MOD]

05/18/2020, 7:13 PM