How can I set an ImageView‘s width and height programmatically?

15 s
15

It may be too late but for the sake of others who have the same problem, to set the height of the ImageView:

imageView.getLayoutParams().height = 20;

Important. If you’re setting the height after the layout has already been ‘laid out’, make sure you also call:

imageView.requestLayout();

Leave a Reply

Your email address will not be published. Required fields are marked *