imageview android的Wave动画
我正在尝试创建一个带有波浪动画的按钮。 我不想改变图像的大小,而是想改变图片和外部的波浪效果 我试过这个:imageview android的Wave动画,android,android-animation,android-imageview,Android,Android Animation,Android Imageview,我正在尝试创建一个带有波浪动画的按钮。 我不想改变图像的大小,而是想改变图片和外部的波浪效果 我试过这个: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <objectAnimator android:propertyName="scaleX" android:duration="200
<?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" />
但这会改变图像的大小,而不是从图像中发送波
我想要这样的东西:
要创建此效果,您需要使用
动画集
,并向其中添加两个动画,一个动画将调整动画大小,基本上改变视图的大小,另一个动画将是淡入淡出的动画,基本上改变此视图的alpha级别
显然,它们将应用于另一个视图,而不是图标视图
代码示例:
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setDuration(1000);
AnimationSet animation = new AnimationSet(true);
animation.addAnimation(sizingAnimation);
animation.addAnimation(fadeOut);
this.setAnimation(animation);
编辑(2020年9月15日):
调整动画大小:
private Animation getResizeAnimation(Context aContext, boolean enlarge) {
Animation resizeAnimation;
if (enlarge) {
resizeAnimation = AnimationUtils.loadAnimation(aContext, R.anim.scale_up_card);
} else {
resizeAnimation = AnimationUtils.loadAnimation(aContext, R.anim.scale_down_card);
}
resizeAnimation.setFillAfter(true);
return resizeAnimation;
}
其中,放大卡
为:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="1.03"
android:toYScale="1.03"
android:pivotX="50%"
android:pivotY="10%"
android:duration="100">
</scale>
</set>
显然,在您的情况下,所需的动画可能不同。要创建此效果,您需要使用
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);
编辑(2020年9月15日):
调整动画大小:
private Animation getResizeAnimation(Context aContext, boolean enlarge) {
Animation resizeAnimation;
if (enlarge) {
resizeAnimation = AnimationUtils.loadAnimation(aContext, R.anim.scale_up_card);
} else {
resizeAnimation = AnimationUtils.loadAnimation(aContext, R.anim.scale_down_card);
}
resizeAnimation.setFillAfter(true);
return resizeAnimation;
}
其中,放大卡
为:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="1.03"
android:toYScale="1.03"
android:pivotX="50%"
android:pivotY="10%"
android:duration="100">
</scale>
</set>
显然,,对于您的情况,可能需要的动画不同。另一个视图并将动画应用于该视图另一个视图并将动画应用于该视图什么是尺寸动画?尺寸动画到底是什么???@KingofMasses尺寸动画添加到了答案中。@VishHistVaruGeese尺寸动画添加到了答案中。尺寸动画是什么?什么确切地说,是尺寸动画吗?@KingofMasses尺寸动画添加到了答案中。@VishistVarugeese尺寸动画添加到了答案中。