Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28537] Android: IMAGE_SCALING_AUTO not stretching ImageView if both width/height is set as of 10.1.0

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2021-09-23T20:40:15.000+0000
Affected Version/sRelease 10.1.0
Fix Version/sRelease 10.1.0
ComponentsAndroid
LabelsImageView, android, regression, scaling
ReporterJoshua Quick
AssigneeJoshua Quick
Created2021-09-20T21:12:55.000+0000
Updated2021-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

FileDateSize
Bad.png2021-09-20T21:10:50.000+0000403599
Good.png2021-09-20T21:10:50.000+0000412820

Comments

  1. Joshua Quick 2021-09-20

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/13077

JSON Source