Hey there,
I have a project, in which the user can login via Facebook or Google. The app then downloads the users profile pictures, and they get displayed different Pages, including a ListView. The problem is that usually profile pictures of facebook or google are quite large. I have a test ListView with 5 entries, and a Photo taken with my SmartPhone that get's displayed in every Cell, and the ListView is already lagging. It's not too bad, but noticeable. In production, the app should be able to support around 10-12 Cells in the ListView. I already tried an ImageCache like this:
public class ImageLoader
{
private Dictionary<string, ImageSource> ImageCache;
public ImageLoader()
{
ImageCache = new Dictionary<string, ImageSource>();
}
public ImageSource GetImageSource(string source)
{
if (ImageCache.ContainsKey(source))
return ImageCache[source];
var image = ImageSource.FromFile(source);
ImageCache[source] = image;
return image;
}
}
so that the images doesn't need to be loaded more than wants (There might be duplicates, it is some sort of Leaderboard).
But this didn't solve it.
So my question: Are there any ways to maybe resize the image, i.e. scale it down before putting it into the ListView's Cell? It works like a charm when I use smaller Images.
My Layout for the Cell consists of 2 nested Grids. But it does already lag on my Samsung Galaxy S8 when I put only the Image into the Cell, so I don't think it's a Layout problem.