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

Xamarin Forms slow loading view.

$
0
0

Hi,

Currently I am trying to retrieve 40 images via a local stored database.
When I recieve the images I am putting a opacity overlay over it and store this in a absolute layout.
But this appears to be very slow, In the past I used the opacity parameter on the images but this was also very slow.


private void SetImages()
{
Grid cardGrid = new Grid();
int column = 0;
int row = 0;

        var tapGestureRecognizer = new TapGestureRecognizer();
        tapGestureRecognizer.Tapped += OnImageClick;
        FileImageSource opacitySource = new FileImageSource { File = "opacity.png" };

        foreach (var image in _cardImageHolder.CardImages)
        {
            image.Scale = 0.8;
            image.GestureRecognizers.Add(tapGestureRecognizer);

            Image opacity = new Image { Source = opacitySource, Scale = 0.8 };

            if (IsSelected(image))
            {
                opacity.Opacity = 0;
                image.Scale = 1;
            }

            _opacity.Add(image.CardId, opacity);
            var parent = new AbsoluteLayout{ Children = { image, _opacity[image.CardId] } };

            cardGrid.Children.Add(parent, column, row);

            if (column < 3)
            {
                column++;
            }
            else
            {
                column = 0;
                row++;
            }
        }

        scrollView.Content = cardGrid;
    }


Viewing all articles
Browse latest Browse all 91519

Trending Articles



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