Book Image

Android UI Development with Jetpack Compose

By : Thomas Künneth
Book Image

Android UI Development with Jetpack Compose

By: Thomas Künneth

Overview of this book

Jetpack Compose is Android’s new framework for building fast, beautiful, and reliable native user interfaces. It simplifies and significantly accelerates UI development on Android using the declarative approach. This book will help developers to get hands-on with Jetpack Compose and adopt a modern way of building Android applications. The book is not an introduction to Android development, but it will build on your knowledge of how Android apps are developed. Complete with hands-on examples, this easy-to-follow guide will get you up to speed with the fundamentals of Jetpack Compose such as state hoisting, unidirectional data flow, and composition over inheritance and help you build your own Android apps using Compose. You'll also cover concepts such as testing, animation, and interoperability with the existing Android UI toolkit. By the end of the book, you'll be able to write your own Android apps using Jetpack Compose.
Table of Contents (16 chapters)
1
Part 1:Fundamentals of Jetpack Compose
5
Part 2:Building User Interfaces
10
Part 3:Advanced Topics

Composing and recomposing the UI

Unlike imperative UI frameworks, Jetpack Compose does not depend on the developer proactively modifying a component tree when changes in the app data require changes to be made to the UI. Instead, Jetpack Compose detects such changes on its own and updates only the affected parts.

As you know by now, a Compose UI is declared based on the current app data. In my previous examples, you have seen quite a few conditional expressions (such as if or when) that determine which composable function is called or which parameters it receives. So, we are describing the complete UI in our code. The branch that will be executed depends on the app data (state) during runtime. The Web framework that React has a similar concept called Virtual DOM. But doesn't this contradict with me saying Compose detects such changes on its own and updates only the affected parts?

Conceptually, Jetpack Compose regenerates the entire UI when changes need to be applied. This...