How to create image animation rotating, with decreasing speed, until stopping

I have this animation below in which an ImagemView rotates on its axis for 4 seconds. It rotates uniformly with the same speed the 4 seconds.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator">
    <rotate
        android:fromDegrees="0"
        android:toDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="4000"
        android:startOffset="0"/>
</set>

How do I make an animation that starts rotating normal but goes down to stop, in the same 4 seconds. Example: a car tire. Ta turning, but when braking the car, this tire will slow down until it stops completely?

Author: ramaral, 2019-04-09

1 answers

The animation is achieved by varying a characteristic, in this case the rotation.

The way this feature varies over time is determined by the Interpolator used.

So, wanting there to be a deceleration, instead of a LinearInterpolator, use a DecelerateInterpolator

<?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator">
        <rotate
            android:fromDegrees="0"
            android:toDegrees="360"
            android:pivotX="50%"
            android:pivotY="50%"
            android:duration="4000"
            android:startOffset="0"/>
    </set>
 3
Author: ramaral, 2019-04-09 09:19:48