How to auto center crop ImageView Android?

孤者浪人 提交于 2019-11-28 17:24:14

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.

Mehroz Munir

i know it's late but maybe it would be helpful for someone coming on this question page by using android:scaleType="centerCrop" image is centered but it is cropped from all sides so it would be better to use this property instead that is fitCenter and with this use another property too to maintain the aspect ratio

android:adjustViewBounds="true"            
android:scaleType="fitCenter"

Are you aware of the cropping options on ImageView?

http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

You will just apply these as an attribute in your XML:

like:

android:scaleType="centerCrop"  

in java: imageView.setScaleType(ScaleType.FIT_XY);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!