Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

FadeTo animation in ListView not executed during scroll in iOS

$
0
0

I created a loader control for an Image. The goal is to show an ActivityIndicator while the image is loading, when the loading is done the image should fade in and the ActivityIndicator should dissapear. In Android everything works fine, but in iOS the animation seem to be executed after the scroll is done or the focus is off the scroll of the listview. Is there a way to execute the animation in iOS during the scroll?


public class LoaderImage : AbsoluteLayout
{

    public ActivityIndicator Loader = new ActivityIndicator();

    public Image Image = new Image();
    public LoaderImage(double w, double h)
    {
        this.HeightRequest = h;
        this.WidthRequest = w;
        Image.WidthRequest = w;
        Image.HeightRequest = h;
        Image.BackgroundColor = Color.Transparent;
        Image.HorizontalOptions = LayoutOptions.FillAndExpand;
        Image.VerticalOptions = LayoutOptions.FillAndExpand;
        Image.Aspect = Aspect.AspectFill;
        Image.IsOpaque = true;

        Image.PropertyChanged += (sender, args) =>
        {
            if (args.PropertyName == "IsLoading")
            {
                if (Image.IsLoading)
                {
                    Image.Opacity = 0;
                }
                else
                {
                    Image.FadeTo(1, 1000);
                }

            }
        };

        if (Xamarin.Forms.Device.OS == TargetPlatform.Android || Xamarin.Forms.Device.OS == TargetPlatform.iOS)
        {

            Loader.WidthRequest = w;
            Loader.HeightRequest = h;
            Loader.VerticalOptions = LayoutOptions.Fill;
            Loader.HorizontalOptions = LayoutOptions.Fill;
            Loader.BackgroundColor = Color.FromRgb(170,170,170);
            Loader.Color = Color.White;
            Loader.BindingContext = Image;
            Loader.IsRunning = true;
            Loader.SetBinding(ActivityIndicator.IsVisibleProperty, "IsLoading");
            Loader.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
        }


        this.Children.Add(Image);
        if (Xamarin.Forms.Device.OS == TargetPlatform.Android || Xamarin.Forms.Device.OS == TargetPlatform.iOS)
        { 
            this.Children.Add(Loader);
        }


    }



}


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>