Chapters

Hide chapters

Android Animations by Tutorials

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

Section II: Screen Transitions

Section 2: 3 chapters
Show chapters Hide chapters

Animating an app is clearly one of the most rewarding, fun and effective ways to enhance the user interface of your android apps. Animations provide visual cues to your users that make the interface fun and easy to use. They give your app a unique flair that make it memoriable and appealing. Everyone enjoys using an app that employs strategic use of animations. They can draw the user’s eye to important parts of the interface, or just add some visual excitement into the design.

You’ve probably seen some impressive animation effects in some of your favorite apps. Effective use of animations means using many different types of animations, from more subtle effects to impressive large animations that really make the content explode from the screen. As an app creator in the Android platform, you’ll need to learn about a lot of different types of animations.

In this book you’ll discover and use many of the most common types of animations found in Android apps today. These include simple view and property animations, transition animations, animating lists and list gestures and even a taste of the popular Jetpack Compose animations. With an arsenal of knowledge like this, you’ll be able to incorporate awesome animations into critical parts of your own apps. By the end of the book after working through the chapters and tackling the challenges at the end, you’ll have gained hands-on experience using a wide array of different types of animations for every occassion.

Are you ready to jump in?

How to read this book

In this book, each chapter will start with the same starter app. This will allow you to really focus on one type of animation at a time while keeping the code less complicated. It also means that you can do the chapters in any order that you please. So don’t hesitate to roll up your sleeves and try whichever animations you’d like. While reading this book, be sure to work through the steps and examine the code samples, and you are encouraged to attempt the challenges as well. The solutions to the challenges are provided in the sample code.

This book is split into four main sections:

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.

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 see the different types of navigation component fragment animations and learn how to apply complex transitions between activities and fragments utilizing animation sets.

Then, you’ll learn how to 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 look attractive.

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 take a close look at utilizing DiffUtil with the ListAdapter to emit intelligent changes to the dataset.

You’ll then move on to ItemTouchHelper animations which animate the items as the user swipes them off or rearranges the items of a list using drag and drop gestures. You’ll learn how to 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 added an item. Your app will allow users to reorder items with drag and drop in style.

Finally, you’ll learn 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.

Section IV: Jetpack Compose Animations

As a final treat, this section will take you through an overview of Jetpack Compose animations. Utilizing AnimatedVisibilty you’ll be able 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.

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.
© 2024 Kodeco Inc.