I have done the entire project (with 3 activities)in jetpack compose. I need one activity to be done with xml and kotlin as I don't know how to do it in jetpack(I'm new to both). Is it possible to integrate the new activity with the rest of the code?
CodePudding user response:
Jetpack Compose and XML view based system are interoperable.
I need one activity to be done with xml
You can add Android Views in Compose
A simple example :
AndroidView(
viewBlock = { context ->
val myView = LayoutInflater.from(context).inflate(R.layout.my_layout, null, false)
val text = myView.findViewById<TextView>(R.id.text)
// do things
myView
},
update = { view ->
// update the view/trigger recomposition
}
)
CodePudding user response:
Yes. You can use both XML and Compose in the same project. By Default, Android Studio create a xml file when you create a new Activity. That it is all :)