How To Change Size Of Imageview Dynamically?
I am creating a dynamic table whose rows contains a imageview and a textview. My problem is this imageview is taking full size of original image but I want to change the size of im
Solution 1:
Have you tried the scaleType-Attribute?
Check out the setMaxWidth
and setMaxHeight
-methods of the ImageView-class:
To set an image to be a maximum of 100 x 100 while preserving the original aspect ratio, do the following: 1) set adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height and width layout params to WRAP_CONTENT.
Solution 2:
Assuming your image is a drawable resource, you can use ScaleDrawable instead, and use the xml attributes android:scaleHeight
and android:scaleWidth
to shrink your image.
Solution 3:
OK I found the Solution
Solution 4:
Try changing your ImageView's layout_width and layout_height inside the layout file to some constant values measured in sp, for example 100sp
. This will make all ImageViews look the same.
Post a Comment for "How To Change Size Of Imageview Dynamically?"