Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Xamarin AnimationEnd事件仅触发一次_C#_Xamarin_Xamarin.android_Android Animation - Fatal编程技术网

C# Xamarin AnimationEnd事件仅触发一次

C# Xamarin AnimationEnd事件仅触发一次,c#,xamarin,xamarin.android,android-animation,C#,Xamarin,Xamarin.android,Android Animation,所以我有几行代码,我试着做一个动画循环。不幸的是,它只会触发一次,而不是每次事件停止时。你能帮帮我吗 ImageView imgView1 = FindViewById<ImageView>(Resource.Id.falling_stars1); ImageView imgView2 = FindViewById<ImageView>(Resource.Id.falling_stars2); Android.Animation.ObjectAnimator anima

所以我有几行代码,我试着做一个动画循环。不幸的是,它只会触发一次,而不是每次事件停止时。你能帮帮我吗

ImageView imgView1 = FindViewById<ImageView>(Resource.Id.falling_stars1);
ImageView imgView2 = FindViewById<ImageView>(Resource.Id.falling_stars2);

Android.Animation.ObjectAnimator animator1 = Android.Animation.ObjectAnimator.OfFloat(imgView1, "y", -700, 100);
Android.Animation.ObjectAnimator animator2 = Android.Animation.ObjectAnimator.OfFloat(imgView2, "y", 100, 900);

animator1.SetDuration(2000);
animator2.SetDuration(2000);
animator1.Start();
animator2.Start();

animator1.AnimationEnd += delegate
{
    animator1.Start();
};

animator2.AnimationEnd += delegate
{
    animator2.Start();
};
ImageView imgView1=findviewbyd(Resource.Id.1);
ImageView imgView2=findviewbyd(Resource.Id.2);
Android.Animation.ObjectAnimator animator1=Android.Animation.ObjectAnimator.offload(imgView1,“y”,-700100);
Android.Animation.ObjectAnimator animator2=Android.Animation.ObjectAnimator.offload(imgView2,“y”,100900);
动画师1.设定持续时间(2000年);
动画师2.设定持续时间(2000年);
animator1.Start();
animator2.Start();
animator1.AnimationEnd+=代理
{
animator1.Start();
};
animator2.AnimationEnd+=代理
{
animator2.Start();
};

RepeatMode:定义动画到达结尾时的行为,并且重复计数大于0或无穷大。

Android.Animation.ObjectAnimator animator1 = Android.Animation.ObjectAnimator.OfFloat(imgView1, "y", -700, 100);
animator1.SetDuration(2000);
animator1.RepeatCount = ValueAnimator.Infinite;
animator1.RepeatMode = ValueAnimatorRepeatMode.Restart;

在此处添加对您建议的更改的描述。我是否可以编辑动画,使其突然结束并开始播放?如果有其他方法可以做到这一点,那么突然结束和开始是什么意思?你想让它停止中间动作吗?我的意思是动画在结尾时稍微慢一点。我希望它在整个过程中保持恒定的速度。我想做一个有两个图像互相跟随的流星后屏,但速度不是恒定的。