Version First Edition
Platform Android 12
Language Kotlin 1.5
Editor Android Studio Artic Fox

This is a book about creating meaningful motion through animation in Android for developers who are familiar with the platform but want to create more visually stunning apps. Starting with simple view animations, this book will move through transition animations including shared element animations, list animations, gestures and scrolling. It ends with a taste of using animations in Jetpack Compose.

Before You Begin

This section tells you a few things you need to know before you get started, such as what you’ll need for hardware and software, where to find the project files for this book, and more.

i

iii

iv

v

Section I: View & Property Animations

In section one, you will begin by learning about the most basic types of animations. You’ll learn how to use ValueAnimator and ObjectAnimator to provide subtle yet meaningful cues to your users. These tools will allow you to to animate the properties of your views. You’ll also learn about the different types of Interpolators that control the rate of change on an animated property. You’ll learn how to apply animations not only to the standard views in the UI tookit, but also how to animate custom views. This will include a demonstration of how to decouple the animation from the internal handling to keep the code structured properly. Oftentimes, you’ll want to reverse an animation, this is included in this section as well.

Last but not least, you’ll get to learn all about XML Animations. XML animations are very convenient to use and render your animation code reusable. You’ll learn about the difference between the anim and animator directories, and when to use each one. The knowledge you gain from this section will help you make more informed decisions about which animations to choose when adding animations in your own app.

Learn how to use Value Animator and Object Animator to animate the different View properties and how to give animations a unique feel using various interpolators.

1

Learn how to use Value Animators and Object Animators to add animations to custom views.

2

Learn how to add animate views using XML.

3

Section II: Screen Transitions

In this section, you’ll learn about one of the most important types of animations found in an app, transitions. Screen transitions help your user understand where they are at when moving from one activity or fragment to another. You’ll begin by animating transitions with XML animations. You’ll create complex transitions between activities and fragments utilizing animation sets. You’ll apply animations to specific views during a transition using the Transition Framework. This will allow you to make even more complex and intriguing transitions between fragments and activities. You’ll also get a primer on how to troubleshoot some of the most common pitfalls you’ll run into when utilizig the transition framework.

Lastly, and most exciting, you’ll learn about Element Transitions. This allows a transition to center the focus around a shared element between two fragments and does not require transitioning the whole view heirarcy. Instead, the shared element takes the center stage and becomes a powerful visual effect. You’ll learn how to do a circular reveal to reveal tab content, and how to use custom transitions to make the transition attractive.

Learn how to use XML animation resources to create real world transitions between activities and fragments.

4

Learn how to use the Transition framework to create transitions between fragments.

5

This chapter covers how to use shared element transitions to create meaningful motion between your screens. You'll also learn how to use circular reveal animations when changing tabs.

6

Section III: List & Gesture Animations

In this section you’ll learn how to use another crucial type of animation for your app, List Animations and Gestures. First, you will work with basic list animations in a recyclerview. You’ll use ItemAnimator to animate the creation, reordering and removal of items in a list. You’ll use ItemTouchHelper animations which animate the items as the user swiptes them off or rearranges the items of a list using drag and drop gestures. You’ll enable gestures on a list to detect swiping and drag and drop reording of items. You’ll use item resetting to visually alert the user that they’ve swiped an item. Your app will allow users to reorder items with drag and drop in style.

You’ll take a close look at how to incorporate animations while the user is scrolling items in a list. You’ll set up scroll listeners, detect the scrolling gestures and how far the list has been scrolled, and respond by updating the UI when scrolling. You’ll learn how to show and hide UI components when scrolling, and how to use CoordinatorLayout with a CollapsingToolbarLayout to acheive a stunning paralax effect when the user scrolls.

Learn how to apply basic list animations to actions like adding and removing items from the list, and how to use DiffUtil to optimize updating your data set.

7

Learn how to implement ItemTouchHelper.Callback to allow swipe and drag gestures for your movie items. Add logic to add and remove movies from favorites by swiping and reordering favorites with drag-and-drop gestures.

8

Learn how to observe and react to scroll gestures to show and hide UI components. Use CoordinatorLayout with a CollapsingToolbarLayout to show different types of UI based on the scroll state.

9

Section IV: Jetpack Compose Animations

This will take you through an overview of Jetpack Compose animations. You’ll use AnimatedVisibilty to look at the state and determine the visibility of the Composables wrapped within it. You’ll learn how to use different types of animations like slide-in or fade-in, and how to apply multiple animations at a time. You’ll also learn about animating the properties of views such as size or color, and how to animate the state changes in your app.

Learn how to add animations to your Jetpack Compose-based apps.

10

Meet the team

Contributors

Who is this book for

This is a book for intermediate developers who know the fundamentals of the Android SDK but are looking for ways to create a beautiful UI with meaningful motion. You should be familiar with the basics of Android development with Kotlin and how to use common Android SDK features. Knowledge about good coding practices is helpful.

Concepts covered in this book

  • Value Animators
  • Object Animators
  • View Animations
  • Interpolators
  • Custom View Animations
  • XML Animations
  • anim
  • animator
  • Transitions Animations
  • Navigation Component XML Transitions
  • Element Transitions
  • Circular Reveal
  • List Animations
  • ItemTouchHelper Animations
  • Drag and Drop Gesture Animations
  • Scrolling Animations
  • Swipe Animations
  • Collapsing Toolbar Animations
  • Jetpack Compose Animations

Reviews

Version history

First Edition · Android 12, Kotlin 1.5, Android Studio Artic Fox

v1.0 · Dec 15 2021 · Alex Sullivan, Filip Babić & Prateek Prasad
See book details
Pro

Android Animations by Tutorials

By Alex Sullivan, Filip Babić and Prateek Prasad

A book about adding meaningful motion to your Android apps that covers a wide variety of APIs available in the Android SDK.

Read for Free with an Ultimate Pro Subscription* * Includes this and all other books in our online library See all benefits
Buy Individually $59.99* *Includes access to all of our online reading features.
See buying options
Hide buying options

All videos. All books.
One low price.

A raywenderlich.com subscription is the best way to learn and master mobile development — plans start at just $19.99/month!

Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.