Is there any concept related to IPhone Aspect Fill within Android.I want to include this same concept on my android image on imageview. Please give me the code snippet for this concept?
Asked
Active
Viewed 2.3k times
3 Answers
75
If you want an ImageView that both scales up and down while keeping the proper aspect ratio, add this to your XML:
android:adjustViewBounds="true"
android:scaleType="centerCrop"
Look this.
-
12This answer is not correct as "fitCenter" does not provide same behaviour than iOS "Aspect Fill". You need to use scaleType="centerCrop" instead. – Christophe Fondacci Apr 06 '14 at 03:58
-
2
-
2If Anybody is Looking for a property that is similar to Apsect FIt in ios (that is image will maintain its aspect ratio and would fit at least one of (X or y)) then android:scaleType = "fiteCenter" would do. – B.shruti May 16 '18 at 07:30
29
I tried fitCenter and it did not work, I ended up using
android:scaleType="centerCrop"
android:adjustViewBounds="true"
inVINCEable
- 2,140
- 3
- 25
- 48
zambono
- 1,358
- 1
- 17
- 26
2
Tested!!! adjustViewBounds needs to be false along with scaleType centerCrop to match UIViewContentModeScaleAspectFill behavior of iOS
android:adjustViewBounds="false"
android:scaleType="centerCrop"
Roohul
- 938
- 1
- 13
- 24