Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

animation with two interpolators

I need to do a animation with two interpolators, for example the animation have 1 seconde of duration for 0 sec to 0.5 sec uses accelerate interpolaor ans for 0.5 to 1 sec use bounce interpolator.

have a way for to do this?

like image 208
ademar111190 Avatar asked Aug 10 '12 19:08

ademar111190


1 Answers

You can try something like this:

<?xml version="1.0" encoding="utf-8"?>
<set 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">

<translate
    android:interpolator="@android:anim/bounce_interpolator"
    android:fromYDelta="0%p"
    android:toYDelta="100"
    android:duration="500"/>

<translate
    android:interpolator = "@android:anim/accelerate_interpolator"
    android:fromYDelta="100"
    android:toYDelta="100"
    android:fromXDelta="0"
    android:toXDelta="100"
    android:startOffset="500"
    android:duration="1000"/>

</set>

This uses two interpolators, the first one is a bounce that moves a view for halve a second. And the second interpolator is an accelerate interpolator that moves a view to the right after halve a second has passed, for a duration of one second. Therefore with a total animation time of 1 second. Hope that helps.

like image 60
0gravity Avatar answered Oct 09 '22 00:10

0gravity