Search code examples
androidmaterial-designfloating-action-button

hide/show fab with scale animation


I'm using custom floatingactionmenu. I need to implement scale animation on show/hide menu button like here floating action button behaviour

Is there any way to do this ?


Solution

  • You can use these scale animations for fab button, it gives same effect like design lib fab button.

    scale_up.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android" >
        <scale
            android:duration="100"
            android:fromXScale="0"
            android:fromYScale="0"
            android:pivotX="85%"
            android:pivotY="85%"
            android:toXScale="1.0"
            android:toYScale="1.0" />
    </set>
    

    scale_down.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android" >
        <scale
            android:duration="100"
            android:fromXScale="1.0"
            android:fromYScale="1.0"
            android:pivotX="85%"
            android:pivotY="85%"
            android:toXScale="0"
            android:toYScale="0" />
    </set>