2

What I Have

I have a Floating Action Button on the bottom of the screen.

What I Want

I want to animate the view when the activity resumes. The animation would grow the FAB from size 0 to fill size, starting from the center and growing in all directions till it finally reaches its full size.

This is just like we see in some of the Material Designed apps.

Aritra Roy
  • 15,355
  • 10
  • 73
  • 107

1 Answers1

6

I got the solution myself actually. It was quite simple.

I created this animation in XMl and saved it in "anim".

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true">

    <scale
        android:duration="250"
        android:fromXScale="0.0"
        android:fromYScale="0.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:pivotX="50%"
        android:pivotY="50%"
        android:startOffset="500"
        android:toXScale="1.0"
        android:toYScale="1.0" />
</set>

After that its just loading and playing the animation on the view,

Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.fab_grow);
        start.startAnimation(animation);

That's it. You are done and good to go.

Aritra Roy
  • 15,355
  • 10
  • 73
  • 107