I have imageView inside a relative layout. And when i create the activity i run thread to grap bitmap from the internet and set the imageView.
What i want is to resize the bitmap to scale based on relative view size while keeping the aspect ratio. The code for resizing the image is working but what i do is i get the relative view size by calling myRelativeView.getWidth() & myRelativeView.getHeight() and i feel that i should not do that because the docs say it could return 0. So what is the best way to retrieve the size of the relative view in this case ?
FIX for your request :]
If you don’t want to change size:
set your
ImageViewscaleTypeto “matrix”If you want to change size but keep aspect ratio:
set your
ImageViewscaleTypeto “fitCenter” (or “fitStart”, “fitEnd”)To change in code:
To Change in XML:
Example