I asked this question on here i was trying to load wide and long images with Glide into a GridView
, and wanted to load these different sized images more uniformly like Picasso does while keeping the aspect ratio as much as possible. The answer i got was its a long standing issue with GridView
s and to try Jake Wharton's aspect ratio image view which i tried without any success. The other suggestion was to make a staggered RecyclerView
, great answer, but a lot of changing
The reason for all of this was my images were too large for Picasso to load quickly and users were complaining that it was really slow, but Glide (which seems much quicker) loads the images to there aspect ratio and messes up the uniformity of my grid, you can see in the link: long images take the same space that 2 wide images do. Anyway, after lots of trial and error I am now using Glide like this:
int width = getActivity().getWindowManager().getDefaultDisplay().getWidth();
int myWidth = width / 2;
Glide.with(getActivity())
.load(mThumbIds[position])
.placeholder(R.drawable.placeholder)
.override(myWidth, myWidth)
.centerCrop()
.into(imageView)
;
I'm new to Android, but this seems to work perfectly. And my question now is other than getWidth
being deprecated, (the app is for API 16+) is there anything wrong with this (getting screen width dividing it and passing it to Glide's resize call)? I think it has to wait to measure the view, but it's still quicker than Picasso was. Can anyone offer anything better?