HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavaCritical

Set ImageView width and height programmatically?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
imageviewandwidthsetheightprogrammatically

Problem

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

Solution

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();

Code Snippets

imageView.getLayoutParams().height = 20;
imageView.requestLayout();

Context

Stack Overflow Q#3144940, score: 1261

Revisions (0)

No revisions yet.