Better Programming

Advice for programmers.

Follow publication

4 Cool Facts About Jetpack Compose

Building UIs in Android just got easier and faster

Mustafa Berkay Mutlu
Better Programming
Published in
4 min readSep 24, 2021
Smartphone
Photo by Andrew M on Unsplash

Jetpack Compose is Google’s newest UI framework to build Android (and desktop) apps. It greatly shifts the approach used in building UI components. It is fully declarative, meaning you describe your UI by calling a series of functions that transform data into a UI hierarchy. It’s unbundled meaning it is backward compatible with older versions of Android and can be updated separately from the Android OS.

But most importantly, it makes writing UI code very easy. How easy, you ask? As easy as the following code:

This short function creates a list in the UI, just like what you would build using RecyclerView.

And you can build any UI in this LazyColumn, imagine developing it by yourself by adding an adapter, ViewHolder, DiffUtil class, and a RecyclerView in the layout.

In this article, I would like to share the most interesting facts I’ve come across while learning Compose.

1. Compose is interoperable with Android Views

You can use Compose in Android Views and Android Views in Compose.

This is great because Compose will work with your existing UI implementation. If you want to add it to your project, you don’t have to go all the way and do it in one go. You can start slow, introduce the basics like theming, styles, and gradually integrate Compose in your codebases. For more details check out this page.

2. A composable function might get executed within a pool of background threads

Unlike Android Views, Compose can run your composable functions (where you declare your UI) in background threads!

It can optimize recomposition (updating the parts of UI where changes occurred) by running composable functions in parallel. This lets Compose take advantage of multiple cores, and run composable…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (2)

Write a response