Answer the question
In order to leave comments, you need to log in
How to find required width and height of three images?
There is a tableRow, three ImageViews are placed in it. The ImageView is loaded with photos of various sizes. It is necessary to rescale each photo (fit to the same height) while respecting the correct width of the images.
I already asked a similar question on this resource, only for two images: link
As a result, for two images I got the following:
float image1Width = Utils.getDownloadedImageWidth(post, indexImage1);
float image2Width = Utils.getDownloadedImageWidth(post, indexImage2);
float image1Height = Utils.getDownloadedImageHeight(post, indexImage1);
float image2Height = Utils.getDownloadedImageHeight(post, indexImage2);
float scale = Math.max(image1Height, image2Height);
float newImage1Width = (scale / image1Height) * image1Width;
float newImage2Width = (scale / image2Height) * image2Width;
float k1 = MainActivity.SCREEN_WIDTH / (image2Width * (image1Height / image2Height + image1Width / image2Width));
float k2 = k1 * (image1Height / image2Height);
float tempHeight1 = k1 * image1Height;
float tempHeight2 = k2 * image2Height;
float tempHeight = Math.max(tempHeight1, tempHeight2);
Answer the question
In order to leave comments, you need to log in
W is the width of the area in which the set of images should be entered
. H is the height of the area.
For the nth picture:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question