Home > DeveloperSection > Forums > Imageview set height by programme
Tanuj Kumar

Total Post:134

Posted on    October-11-2014 12:53 AM

 Android Android  Mobile Development 

 1 Reply(s)
 807  View(s)
Rate this:
I want to set the height of the image view programatically in gridview. I used below code-

imageview.getLayoutParams().height = height;

This is working fine in android version 4.3 and higher but not working in android version 4.2 and below. I can't find the issue. Any help please.

ImageView in xml-






 android:background="@drawable/top_radius" />

Kamlakar Singh
Kamlakar Singh

Total Post:194

Posted on    October-11-2014 12:55 AM

This is a simple way to set dimensions of imageview.

ImageView iv = (ImageView)findViewById(R.id.imageview);

int width = 60;

int height = 60;

LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(width, height);


Don't want to miss updates? Please click the below button!

Follow MindStick