Home > Software design >  Is it possible to mix jetpack compose with components that are not available in jetpack compose?
Is it possible to mix jetpack compose with components that are not available in jetpack compose?

Time:01-16

I am starting with Jetpack compose for android. I like it so far. I am a bit skeptical of starting a new project with it, though. I know not all types of views are available on Jetpack.

For example I would like to use 3rd party libraries to render graphs in the app. But, these libraries are provide you the traditional views that you either inflate programatically or use it xml. Is it possible to have some views defined in xml while some from compose? Is jetpack compose mature enough to start using in production applications?

CodePudding user response:

If you want to use xml widgets inside your compose views, you can use the composable AndroidView for that:

AndroidView(
    factory = { context ->
        TextView(context)
    }
)

See the documentation on Views in Compose.

CodePudding user response:

Yes, Jetpack Compose is ready to use in Android. Whether to use it or not is a question about your experience :) There are some non-intuitive behaviours like read-defer lambdas, so You must be aware of them before start. A lot of top high-tech companies already use it.

I don't understand what do You mean in "3rd party libraries to render graphics", maybe You mean some custom libraries for UI like Charts? If Yes, then You will have Activity with Fragments with UI on xml and use Jetpack Compose views being injected into xml layout. That's how developers integrate Compose in existing xml-based applications.

  • Related