Wave动画供ImageView android使用

OSh*_*fer 1 android android-animation android-imageview

我正在尝试用wave动画创建一个按钮。我不想更改图像的大小,而是要从图片和外部进行波浪效果。

我尝试了这个:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

<objectAnimator
    android:propertyName="scaleX"
    android:duration="2000"
    android:valueFrom="1.0"
    android:valueTo="1.3"
    android:repeatMode="reverse"
    android:repeatCount="infinite"
    android:valueType="floatType" />

<objectAnimator
    android:propertyName="scaleY"
    android:duration="2000"
    android:valueFrom="1.0"
    android:valueTo="1.3"
    android:repeatMode="reverse"
    android:repeatCount="infinite"
    android:valueType="floatType" />
Run Code Online (Sandbox Code Playgroud)

但这会更改图像的大小,而不是发送图像。

我想要这样的东西:

波浪动画示例图像

Emi*_*Adz 5

要创建此效果,您将需要使用AnimationSet,并向其中添加两个动画,一个动画将调整动画的大小,基本上改变视图的大小,另一个动画将是褪色的动画,基本上改变该视图的Alpha级别。

显然,它们将应用于其他视图而不是图标视图。

代码示例:

Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setDuration(1000);

AnimationSet animation = new AnimationSet(true);
animation.addAnimation(sizingAnimation);
animation.addAnimation(fadeOut);
this.setAnimation(animation);
Run Code Online (Sandbox Code Playgroud)