Juwei
Juwei

Reputation: 261

Android animation: bouncing button like on mac

If i open an application on a mac os x the app button is bouncing like a ball, high up and then 2x not so high and same again. Can this be done using an bouncing animation or some other kind of animation?

The Button should like like to jump to the user out of the phone (growing a bit) and then shrinking 2 times before it starts over again with the big one. Just like throwing a ball straight down from viewers eyes to the display.

I want to get the attention of the user that this button is waiting to be clicked :)

This is what i got:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:duration="400"
        android:fromXScale="1"
        android:fromYScale="1"
        android:interpolator="@android:anim/bounce_interpolator"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="1.1"
        android:toYScale="1.1"
        android:repeatCount="4" />
</set>

And start it with

Animation bounce = AnimationUtils.loadAnimation(5his, R.anim.bounce);
somebutton.startAnimation(bounce);

But its just increasing within 400 seconds to 110% and then start over from 100%. No ball bouncing effect.

Any ideas?

Upvotes: 4

Views: 2659

Answers (1)

Juwei
Juwei

Reputation: 261

Ah, bounce_interpolator is already doing what i want, i just need to give the animation more time... android:duration="1000" did the trick, the 400ms was too fast to see the bouncing animation.

Upvotes: 5

Related Questions