How to auto center crop ImageView Android?

lopez.mikhael picture lopez.mikhael · Jul 19, 2013 · Viewed 81.8k times · Source

I made a listView images. My goal that each item of my listView have the same height of 100dp. I encounter a problem that my imageView is resized automatically, but does not take the entire space of the parent.

Here is my current result and objectif result :

Resized Image objectif

Does anyone know the option to add to make crop center automatically?

Answer

Naresh R picture Naresh R · Jul 19, 2013

I am not sure if I understood correctly. It must be either of the two, that you want, I guess.

In your image view set the attribute

android:scaleType="fitXY"

to fit the ImageView completely.

You can choose

android:scaleType="centerCrop"

to crop Center.