简体   繁体   English

将浮动操作按钮转换为Android中的活动

[英]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? 有没有办法像Google的Material设计指南一样制作动画? I'm talking about something like this (from here ). 我说的是像这样 (从这里 )。

As i have created a file in anim folder 因为我在anim文件夹中创建了一个文件

right_bottom_up.xml 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 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 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 在你的第二个活动onBackPress()中写下这一行

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

Refer Below lib project , its same as you share video in this question. 请参阅下面的lib项目,与您在此问题中分享视频相同。

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

May be this definitely helps you. 可能这绝对可以帮到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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