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.
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.
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.
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.
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 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.
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.
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.
Marta is a book enthusiast. You will find her reading at any time of day and night.
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
Concepts covered in this book
Custom View Animations
Navigation Component XML Transitions
Drag and Drop Gesture Animations
Collapsing Toolbar Animations
Jetpack Compose Animations
First Edition · Android 12, Kotlin 1.5, Android Studio Artic Fox
v1.0 · Dec 15 2021 · Alex Sullivan, Filip Babić & Prateek Prasad