I'm working with an ImageView and I want to resize it programmatically passing (for example) from a full-screen ImageView to a 50x50. Is there a way to do that? Different from the one you suggested me to see because I don't need to fit the image in the ImageView but to resize the dimension of the ImageView.
Asked
Active
Viewed 1,938 times
2
-
2Possible duplicate: https://stackoverflow.com/a/8233084/3780625 – Maxouille Mar 04 '19 at 12:33
-
Possible duplicate of [Fit image into ImageView, keep aspect ratio and then resize ImageView to image dimensions?](https://stackoverflow.com/questions/8232608/fit-image-into-imageview-keep-aspect-ratio-and-then-resize-imageview-to-image-d) – Santhosh Kumar Mar 04 '19 at 12:35
3 Answers
1
My suggestion use a relative layout and put image inside that has with weight and able to auto resize which depends on the weight. The best way to auto resize even your screen rotates.
I didn't remember which one layout has weight format

Mystogan
- 114
- 2
- 13
1
You can use LayoutParams
to set height width programmatically -
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
layoutParams.width = 30;
layoutParams.height = 30;
imageView.setLayoutParams(layoutParams);

Al-Amin
- 1,369
- 1
- 9
- 26
0
ConstraintLayout provides a mechanism for fixing the aspect ratio of a child view. Select the child view that we want to control, and then set the ratio value, we can manually put the ratio that we want to set. Using constraintLayout makes UI shrink or expand according to screen size without distorting the UI. This is the most important advantage of using ConstraintLayout in UI.

Tanveer singh Bhatia
- 69
- 9