[TIMOB-28537] Android: IMAGE_SCALING_AUTO not stretching ImageView if both width/height is set as of 10.1.0
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2021-09-23T20:40:15.000+0000 |
| Affected Version/s | Release 10.1.0 |
| Fix Version/s | Release 10.1.0 |
| Components | Android |
| Labels | ImageView, android, regression, scaling |
| Reporter | Joshua Quick |
| Assignee | Joshua Quick |
| Created | 2021-09-20T21:12:55.000+0000 |
| Updated | 2021-09-23T20:40:15.000+0000 |
Description
*Summary:*
As of 10.1.0, the new ImageView [scalingMode](https://titaniumsdk.com/api/titanium/ui/imageview.html#scalingmode) property which defaults to [Ti.Media.IMAGE_SCALING_AUTO](https://titaniumsdk.com/api/titanium/media.html#image_scaling_auto) is supposed to stretch the image disproportionally if both the "width" and "height" properties are defined. If only 1 of the "width" or "height" properties are defined (or neither), then it's supposed to do a [Ti.Media.IMAGE_SCALING_ASPECT_FIT](https://titaniumsdk.com/api/titanium/media.html#image_scaling_aspect_fit) which is a letterbox scale. This is to match the old scaling behavior before Titanium 10.1.0.
As of 10.1.0.RC, setting both "width" and "height" with the default
Ti.Media.IMAGE_SCALING_AUTO mode no longer stretches the image disproportionally anymore on Android. It's always doing a letterbox scale.
*Steps to reproduce:*
Build and run the below on Android.
Notice the image is wrongly scaled proportionally when it should be stretched width-wise.
const win = Ti.UI.createWindow();
win.add(Ti.UI.createImageView({
image: "https://raw.githubusercontent.com/appcelerator/titanium_mobile/master/templates/app/angular-default/template/DefaultIcon.png",
width: Ti.UI.FILL,
height: 30,
}));
win.open();
*Result:*
Notice the image is proportionally scaled to the "height" property's value of 30. This is wrong since both "width" and "height" properties are defined. _(The below would only be correct if only the "width" property was defined.)_
!Bad.png|thumbnail!
*Expected Result:*
The image should be stretched as follows.
!Good.png|thumbnail!
Attachments
| File | Date | Size |
|---|---|---|
| Bad.png | 2021-09-20T21:10:50.000+0000 | 403599 |
| Good.png | 2021-09-20T21:10:50.000+0000 | 412820 |
PR (master): https://github.com/appcelerator/titanium_mobile/pull/13077