Reader small image

You're reading from  Android UI Development with Jetpack Compose - Second Edition

Product typeBook
Published inNov 2023
Reading LevelN/a
PublisherPackt
ISBN-139781837634255
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Thomas Künneth
Thomas Künneth
author image
Thomas Künneth

Thomas Künneth is a Google Developer Expert for Android and has been a speaker and panelist at multiple international conferences about Android. Currently, Thomas works as a senior Android developer at Snapp Mobile. He has authored countless articles as well as one of the top-selling German Android books (currently in its sixth edition). He has also frequently contributed to various open source projects.
Read more about Thomas Künneth

Right arrow

Preface

Jetpack Compose is a paradigm shift in Android development and introduces a lot of new concepts that are essential for any Android developer to learn. It solves a lot of pain points that are associated with Android development, and it is touted to be the default way to build Android apps over the next few years.

Using practical examples, you will learn about the fundamental concepts of Jetpack Compose and how to use them when you build your own Android applications. The book starts with an in-depth explanation of the declarative approach, its differences, and its advantages over traditional UI frameworks. Having laid this foundation, we will get practical and write our first composable functions. After that, we will cover layouts, an important core component of every UI framework. Having mastered them, we will move on to more advanced topics such as animation, testing, and architecture best practices.

The second edition has been thoroughly updated to reflect all changes and additions that were made by Google since the initial stable release. All examples are based on Material 3 (also named Material You).

Who this book is for

This book is for Android developers with existing knowledge of the Kotlin programming language, who would like to learn how to build modern Android user interfaces (UIs) using Jetpack Compose.

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.

To get the most out of this book

Software/hardware covered in the book

Operating system requirements

Android Studio Giraffe or later versions

Windows, macOS, or Linux

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Android-UI-development-with-Jetpack-Compose-Second-Edition. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Column() contains two children, Button() and Image(). The image is visible only when showImage is true.”

A block of code is set as follows:

class MainActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
      MainView()
    }
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

TextField(
    value = name.value,
    onValueChange = {
        name.value = it
    },
    placeholder = {
        Text(text = stringResource(id = R.string.hint))
    },

Any command-line input or output is written as follows:

$ mkdir css
$ cd css

Bold: Indicates a new term, an important word, or words that you see on screen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “To deploy a composable function to a real device or the Android Emulator, click on the Run Preview button.”

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read Android UI Development with Jetpack Compose, we’d love to hear your thoughts! Please click here to go straight to the Amazon review pagefor this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?

Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

  1. Scan the QR code or visit the link below

https://packt.link/free-ebook/9781837634255

  1. Submit your proof of purchase
  2. That’s it! We’ll send your free PDF and other benefits to your email directly
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Android UI Development with Jetpack Compose - Second Edition
Published in: Nov 2023Publisher: PacktISBN-13: 9781837634255
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Thomas Künneth

Thomas Künneth is a Google Developer Expert for Android and has been a speaker and panelist at multiple international conferences about Android. Currently, Thomas works as a senior Android developer at Snapp Mobile. He has authored countless articles as well as one of the top-selling German Android books (currently in its sixth edition). He has also frequently contributed to various open source projects.
Read more about Thomas Künneth