How can I set an
ImageView's width and height programmatically?
It may be too late but for the sake of others who have the same problem, to set the height of the ImageView:
image_view.getLayoutParams().height = 20;
Hope this helps.
Important. If you're setting the height after the layout has already been 'laid out', make sure you also call:
If your image view is dynamic, the answer containing getLayout will fail with null-exception.
In that case the correct way is:
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(100, 100); iv.setLayoutParams(layoutParams);