Chapter 18. Jetpack Compose: Compose Yourself
All the UIs you’ve built so far have used views and layout files.
But with Jetpack Compose, that’s not the only option. In this chapter, we’re going to take a road trip to Composeville, and find out how to build UIs using Compose components called composables instead of views. You’ll learn how to use built-in composables such as Text, Image, TextField, and Button. You’ll discover how to arrange them in Rows and Columns, and style them using themes. You’ll write and preview your own composable functions. You’ll even find out how to manage a composable’s state using MutableState objects. Turn the page, and let’s get composing…
UI components don’t have to be Views
So far in this book, you’ve learned how to use layout files and views to build swish, interactive UIs. But while we’ve focused on this approach, it’s not your only option.
An alternative is to build your UI using Jetpack Compose. Compose is part of Android Jetpack; it’s an entire toolkit of libraries, tools, and APIs designed to help you build native UIs with pure Kotlin code.
The great news is that using Jetpack Compose builds on your existing Android knowledge. You can use view models and live data with Compose, for example, and even add Compose components to existing UIs.
Note
You’ll find out more about this in the next chapter.
We’re going to build a Compose app
In ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access