If you are using Picasso, first create your own ImageView
public class DynamicHeightImageView extends ImageView { private double mHeightRatio; public DynamicHeightImageView(Context context, AttributeSet attrs) { super(context, attrs); } public DynamicHeightImageView(Context context) { super(context); }
Then in your onBindViewHolder
Picasso.with(context).load(modal.image.mediumUrl).into(holder.profileImage, new Callback() { @Override public void onSuccess() { holder.profileImage.setHeightRatio(holder.profileImage.getHeight()/holder.profileImage.getWidth()); } @Override public void onError() { } });
randy
source share