When making waterfall flow in the project, I wanted to scale the image according to the screen scale. I didn’t use it in the end, but I made a brief note of the method
Glide allows us to get the image width and height after the resource is ready
Glide.with(mContext).load(list.get(position).getImageUrl()) .error(R.drawable.home_banner_load_error) .into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @nullable Transition<? Super Drawable> Transition) {// resource.getHeight; }});Copy the code
In addition, if you do not use Glide, there is another idea, we can use BitmapFactory Options to get the width and height of the image.