Adding Compose to existing projects
In this section, we will look at what options we have in terms of introducing Jetpack Compose into an existing Android application and how to get Compose to work with different libraries.
When using Jetpack Compose, you should ideally have a small number of activities, or one if possible, and have all your screens built using Compose. For an existing project to be able to achieve this, it would need to start at the bottom of the View
hierarchy, meaning that your existing views should start being migrated to be built in Compose.
To facilitate this transition, Jetpack Compose offers the possibility of using ComposeView
in your XML layout, as in the following example:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:orientation="vertical"...