Android: scaleType expands to screen

I need to resize multiple images inside ImageView to screen size. I am currently using scaleType = "centerInside", it is great for large images to scale them to screen size, but does not expand small images.

All other options offered crop or warp the image. Is there a way to extend the images (preservation relation) via XML or do I need to do this manually in the code?

+3
source share
4 answers

You will be limited in how much you can make only from XML. The easiest way to extend the low resource is to determine the properties android:layout_widthand android:layout_heightthe desired (using the density of pixels independent of dip ). android:layout_width="320dip"will expand you to full screen width (in portrait mode).

If your images are photographs or something with different proportions, then your only choice may be to inflate the view from the code (after determining the correct size).

+2
source

Just try it scaleType="fitXY". It will enlarge or reduce the image exactly to the size of the image.

0
source

scaleType="fitCenter" .

0

Source: https://habr.com/ru/post/1776108/


All Articles