Book Image

Android UI Development with Jetpack Compose - Second Edition

By : Thomas Künneth
5 (1)
Book Image

Android UI Development with Jetpack Compose - Second Edition

5 (1)
By: Thomas Künneth

Overview of this book

Compose has caused a paradigm shift in Android development, introducing a variety of new concepts that are essential to an Android developer’s learning journey. It solves a lot of pain points associated with Android development and is touted to become the default way to building Android apps over the next few years. This second edition has been thoroughly updated to reflect all changes and additions that were made by Google since the initial stable release, and all examples are based on Material 3 (also called Material You). This book uses practical examples to help you understand the fundamental concepts of Jetpack Compose and how to use them when you are building your own Android applications. You’ll begin by getting an in-depth explanation of the declarative approach, along with its differences from and advantages over traditional user interface (UI) frameworks. Having laid this foundation, the next set of chapters take a practical approach to show you how to write your first composable function. The chapters will also help you master layouts, an important core component of every UI framework, and then move to more advanced topics such as animation, testing, and architectural best practices. By the end of this book, you’ll be able to write your own Android apps using Jetpack Compose and Material Design.
Table of Contents (18 chapters)
Part 1: Fundamentals of Jetpack Compose
Part 2: Building User Interfaces
Part 3: Advanced Topics

What this book covers

Chapter 1, Building Your First Compose App, shows you how to build your first Compose app. Also, important key ideas such as composable functions and using previews are introduced. It is important to whet the appetite by offering early success, so we will build, preview, and run composable functions before digging too deep into details.

Chapter 2, Understanding the Declarative Paradigm, explains how Android UI development was done before Jetpack Compose and what the issues with this “old” approach are. Also, you will discover how composables are different from views and why this is both important and beneficial.

Chapter 3, Exploring the Key Principles of Compose, explores important terminology, concepts, and techniques. Their knowledge is essential to write well-behaving Compose apps.

Chapter 4, Laying Out UI Elements in Compose, examines how the way Jetpack Compose’s layout system works is different compared to the classic Android UI toolkit. This chapter introduces some of the existing layouts. It also shows you how to implement custom layouts. These are needed if the built-in layouts cannot provide the required distribution of UI elements on screen.

Chapter 5, Managing State of Your Composable Functions, details why reacting to state changes is critical to how modern mobile apps work. Jetpack Compose tries to address this need by providing reactive state primitives. This chapter looks at how to use these state primitives and how they work under the hood.

Chapter 6, Building a Real-World App, revisits previously learned concepts and brings them together in one app. Seeing concepts in actual code will help you to understand them and make it easier to reuse in your own programs.

Chapter 7, Exploring App Architecture, further explores ViewModels and how they can help build a solid app architecture. You will learn how to inject objects such as repositories during ViewModel creation and why this is important. The chapter also introduces side effects as a means to trigger or react to changes outside the Compose world.

Chapter 8, Working with Animations, contains a detailed look at animations and transitions. Using them makes apps really shine. Jetpack Compose simplifies the process of adding animation effects greatly over the old view-based approach. This chapter introduces all the relevant APIs.

Chapter 9, Exploring Interoperability APIs, explains how to mix Jetpack Compose and old-fashioned views in one app. Although Jetpack Compose is the UI toolkit of choice for new apps, its powers can be leveraged in existing apps, too. This chapter discusses strategies to combine both declarative and imperative approaches in one app and offers a migration strategy to painlessly update existing UIs to Jetpack Compose.

Chapter 10, Testing and Debugging Compose Apps, explains why testing the UI of a Compose app works differently than testing a view-based UI. Compose uses a more declarative approach to testing. This chapter introduces basic testing scenarios for Compose apps.

Chapter 11, Developing for Different Form Factors, shows you how to write Compose apps that look great not only on smartphones but also on large-screen devices, such as tablets and foldables. It introduces the concept of Window Size Classes and shows you how they are used to organize screen content.

Chapter 12, Bringing Your Compose UI to Different Platforms, shows you how to bring Compose UIs to different platforms such as the desktop (Windows, Linux, or macOS) and the web. It offers a quick introduction to Compose Multiplatform and related technologies such as Kotlin Multiplatform (KMP). You will learn how to take one of the sample apps of the book to the desktop.