Defining Custom Animations
Stay organized with collections
Save and categorize content based on your preferences.
This page is deprecated. See below for the new location for
documentation that used to be here.
Customize Touch Feedback
Touch feedback in material design provides an instantaneous visual confirmation at the
point of contact when users interact with UI elements. The default touch feedback animations
for buttons use the new RippleDrawable
class, which transitions
between different states with a ripple effect.
In most cases, you should apply this functionality in your view XML by specifying the view
background as:
?android:attr/selectableItemBackground
for a bounded ripple.
?android:attr/selectableItemBackgroundBorderless
for a ripple that extends beyond
the view. It will be drawn upon, and bounded by, the nearest parent of the view with a non-null
background.
Note: selectableItemBackgroundBorderless
is a new
attribute introduced in API level 21.
Alternatively, you can define a RippleDrawable
as an XML resource using the ripple
element.
You can assign a color to RippleDrawable
objects. To change
the default touch feedback color, use the theme's android:colorControlHighlight
attribute.
For more information, see the API reference for the RippleDrawable
class.
Use the Reveal Effect
See Create a circular reveal animation.
Customize Activity Transitions
See Start an Activity with an Animation.
Use Curved Motion
See Use curved motion.
Animate View State Changes
See Using StateListAnimator to
animate view state changes.
Animate Vector Drawables
See Animate Drawable Graphics.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-05-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-20 UTC."],[],[],null,["# Defining Custom Animations\n\n**This page is deprecated.** See below for the new location for\ndocumentation that used to be here.\n\nCustomize Touch Feedback\n------------------------\n\nTouch feedback in material design provides an instantaneous visual confirmation at the\npoint of contact when users interact with UI elements. The default touch feedback animations\nfor buttons use the new [RippleDrawable](/reference/android/graphics/drawable/RippleDrawable) class, which transitions\nbetween different states with a ripple effect.\n\nIn most cases, you should apply this functionality in your view XML by specifying the view\nbackground as:\n\n- `?android:attr/selectableItemBackground` for a bounded ripple.\n- `?android:attr/selectableItemBackgroundBorderless` for a ripple that extends beyond the view. It will be drawn upon, and bounded by, the nearest parent of the view with a non-null background.\n\n**Note:** `selectableItemBackgroundBorderless` is a new\nattribute introduced in API level 21.\n\nAlternatively, you can define a [RippleDrawable](/reference/android/graphics/drawable/RippleDrawable)\nas an XML resource using the `ripple` element.\n\nYou can assign a color to [RippleDrawable](/reference/android/graphics/drawable/RippleDrawable) objects. To change\nthe default touch feedback color, use the theme's `android:colorControlHighlight`\nattribute.\n\nFor more information, see the API reference for the [RippleDrawable](/reference/android/graphics/drawable/RippleDrawable) class.\n\nUse the Reveal Effect\n---------------------\n\nSee [Create a circular reveal animation](/training/animation/reveal-or-hide-view#Reveal).\n\n\nCustomize Activity Transitions\n------------------------------\n\nSee [Start an Activity with an Animation](/training/transitions/start-activity).\n\nUse Curved Motion\n-----------------\n\nSee [Use curved motion](/training/animation/reposition-view#CurvedMotion).\n\nAnimate View State Changes\n--------------------------\n\nSee [Using StateListAnimator to\nanimate view state changes](/guide/topics/graphics/prop-animation#ViewState).\n\nAnimate Vector Drawables\n------------------------\n\nSee [Animate Drawable Graphics](/guide/topics/graphics/drawable-animation)."]]