Why use Jetpack Compose?

Antroid
4 min readMay 2, 2023

Jetpack Compose is a declarative UI toolkit for building native Android Application. It simplifies the process of creating user interface by allowing developers to describe the desired UI state and compose take care of updating UI automatically. Unlike traditional XML layouts, Compose uses Kotlin based (DSL) Domain specific Language to define UI elements.

Now one might think why to use Compose? Why did even Android team at Google decide to introduce something different when existing Android application were doing great with XML ui layouts?
Lets try to conclude by looking at the below problems that Compose addresses .

  1. Complex and Verbose XML Layout :

XML layouts can become complex and difficult to maintain. Compose uses Kotlin based DSL resulting in more concise code. For example:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome to my app!"
android:textSize="20sp"
android:textStyle="bold" />

<EditText
android:id="@+id/input_field"…

--

--

Antroid

Android Tech Lead , spreading out my learnings. Way to Go