xamarin 表单中的帧动画

Frame animation in xamarin forms

我想制作帧动画,但不确定是否应该使用 AnimationDrawable class 制作动画。 Android 如何在 Xamarin 表单中制作帧动画。还有其他方法吗?简单的例子就完美了。

我只是隐藏和取消隐藏所需的元素。您可以通过单击任何按钮或其他方式从 DoAnimation 调用。

private void DoAnimation()
{
    _timer = new System.Timers.Timer();
    //Trigger event every second
    _timer.Interval = 1000;
    _timer.Elapsed += CheckStatus;
    //count down 5 seconds
    _countSeconds = 5000;
    _timer.Enabled = true;

}
private void SpinAnimation()
{
switch (_letterShowState) {
case SomeStateStates.State1:
    _pic1.IsVisible = false;
    _pic2.IsVisible = true;
    _pic3.IsVisible = false;
    _letterShowState = SomeStateStates.State2;
    break;
    }
    }

private void CheckStatus(object sender, System.Timers.ElapsedEventArgs e) {
    _countSeconds--;
    new System.Threading.Thread(new System.Threading.ThreadStart(() => {
        Xamarin.Forms.Device.BeginInvokeOnMainThread(() => {
            SpinAnimation();
        });
    })).Start();

    if (_countSeconds == 0)
    {
        _timer.Stop();
    }
}