android - android中 float Action 按钮的简单动画?

标签 android android-animation floating-action-button

我需要一个非常简单的解释,说明如何在单击此“添加到购物车”FloatingActionButton 时对其进行动画处理。我想要的只是一个流畅的“左右”或“上下”运动动画。

请看下面的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:weightSum="1"
    android:background="@color/cardview_light_background">    

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.FloatingActionButton
            android:layout_width="54dp"
            android:layout_height="54dp"
            android:layout_gravity="bottom|right"
            android:src="@mipmap/ic_add_shopping_cart_black_24dp"
            android:layout_marginBottom="40dp"
            android:layout_marginRight="30dp"
            app:backgroundTint="@android:color/holo_blue_light" />

    </android.support.design.widget.CoordinatorLayout>
</LinearLayout>

提前致谢!

最佳答案

尝试 AndroidViewAnimations图书馆。这个库提供了简单的方法来动画你的 View 。有很多效果。例如

YoYo.with(Techniques.Tada)
.duration(700)
.playOn(findViewById(R.id.edit_area));

关于android - android中 float Action 按钮的简单动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42055571/

相关文章:

Android线程等待直到可见

android - 以编程方式更改 float 按钮图像大小

ionic-framework - Ionic FabButton 无法在 iPhone 上正常工作

android - 如何控制谁可以从 Play 商店安装我的应用程序?

android - 我无法在 termux 上安装 tkinter

android - 将 base64 图像从 Android 发布到 Azure 移动后端

android - Android 中的旋转动画序列

android - MvvmCross Android - 替代按钮命令的 RelativeSource 绑定(bind)

android - 在 Android Canvas 下动画形状的最佳实践

两个 Activity 之间的Android共享元素转换不起作用