Wave动画供ImageView android使用 [英] Wave animation for imageview android

查看:78
本文介绍了Wave动画供ImageView android使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to create a button with wave animation. I do not want to change the size of the image, but to do effect of waves from the picture and outside.

我尝试过:

<?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" />

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

But this changes the size of the image instead of sending a wave from it.

我想要这样的东西:

推荐答案

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

To create this effect you will need to use AnimationSet, And add to it two animations, one animation would be resizing animation, basically changing the size of the view, the other animation would be a fading animation basically changing the alpha level of this view.

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

obviously they would be applied to another view and not the icon view.

代码示例:

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

AnimationSet animation = new AnimationSet(true);
animation.addAnimation(sizingAnimation);
animation.addAnimation(fadeOut);
this.setAnimation(animation);

这篇关于Wave动画供ImageView android使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆