Set ImageView width and height programmatically?

To set ImageView width and height programmatically

imageview.getLayoutParams().height = 20;

here imageview is instance of ImageView.

Important: If you’re setting the height after the layout has already been ‘laid out’, then make sure you call imageview.requestLayout()

Here is the ref link, credits to Hakem Zaied

Hope this helps.

Leave a Reply

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