简体   繁体   中英

Transform a Floating action button into an activity in Android

I have a floating action button that, when pressed, starts a new activity.

Is there a way to animate it like on Google's Material design guidelines? I'm talking about something like this (from here ).

As i have created a file in anim folder

right_bottom_up.xml

 <?xml version="1.0" encoding="utf-8"?>
<translate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@integer/time_fade"
    android:fromXDelta="100%p"
    android:fromYDelta="100%p"
    android:toYDelta="0%p"
    android:toXDelta="0%">
</translate>

no_animation.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@android:integer/config_longAnimTime"
   ></translate>

slide_down_back.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="@integer/time_fade"
    android:fromYDelta="0%p"
    android:toYDelta="100%p"></translate>

In activity start your activity after intent calling:

 overridePendingTransition(R.anim.right_bottom_up, R.anim.no_animation);

in your second activity onBackPress() write this line

    overridePendingTransition(R.anim.no_animation, R.anim.slide_down_back);

Refer Below lib project , its same as you share video in this question.

https://github.com/gowong/material-sheet-fab

May be this definitely helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM