Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Show ImageView trimmed so that the height is equal to the width?

I need to make an Android Application that displays a square image. But receives images of a width greater than high. But you need to show square.

This is what I have.

enter image description here

This is what I need

enter image description here

like image 415
ihojose Avatar asked Dec 14 '25 00:12

ihojose


1 Answers

You can use these two parameters in ImageView in xml:

android:adjustViewBounds="true"
android:scaleType="centerCrop"
like image 198
RediOne1 Avatar answered Dec 16 '25 13:12

RediOne1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!