Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14395] Android: ImageView scaling not consistent with samples in documentation

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-10-13T20:45:11.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 21, 2013 Sprint 21 API, Release 3.2.0
ComponentsAndroid
Labelsn/a
ReporterBen Sudbury
AssigneeSunila
Created2013-06-19T00:11:29.000+0000
Updated2014-10-24T17:01:05.000+0000

Description

The following code was used in the documentation for ImageViews for the latest SDK see: [Images and ImageView API's](http://docs.appcelerator.com/titanium/latest/#!/guide/Images_and_ImageView_APIs)
var win1 = Titanium.UI.createWindow({  
    backgroundColor:'#fff'
});

var imageView = Titanium.UI.createImageView({
	image:"/iphone/appicon.png",
	width: 57,
	height: 100,
	backgroundColor: "red"
})

win1.add(imageView);

win1.open();
The code is expected to output a result that looks like this: !http://docs.appcelerator.com/titanium/latest/images/download/attachments/29004912/imagescaling.png! Instead, it outputs this: !SkewedImage.png!

Attachments

FileDateSize
NotEnlarged.png2013-06-19T00:20:50.000+000022734
SkewedImage.png2013-06-19T00:11:29.000+000027563

Comments

  1. Ben Sudbury 2013-06-19

  2. Ben Sudbury 2013-06-19

    A slightly different example but also not scaling as per the documentation. If you change the Width to be larger than the image and the Height to be Ti.UI.SIZE, the image is not scaled up at all. So, the following code:
       var win1 = Titanium.UI.createWindow({  
           backgroundColor:'#fff'
       });
       
       var imageView = Titanium.UI.createImageView({
       	image:"/iphone/appicon.png",
       	width: 87,
       	height: Ti.UI.SIZE,
       	backgroundColor: "red"
       })
       
       win1.add(imageView);
       
       win1.open();
       
    Results in the following output: !NotEnlarged.png! Note: That scaling is working perfectly for width equal to or less than true image width and Height = Ti.UI.SIZE
  3. Carter Lathrop 2013-06-26

    Thanks Ben, tested and confirmed on 3.1.1GA & 3.1.0GA, bug occurs on both iOS and Android. Since this ticket has a better test case (as in in classic Titanium) I will move this to engineering and mark other as duplicate. Thanks again for bringing this to our attention. Regards, Carter
  4. Joe Falcone 2013-08-22

    This is a pretty serious bug for folks displaying images in their apps. We've had to resort to showing images in webViews which is a much more costly alternative. This is preventing us from migrating to 3.1 for some of our apps.
  5. Ingo Muschenetz 2013-08-22

    [~jfalcone] I've tentatively scheduled this for 3.2.0
  6. Sunila 2013-09-26

    The test case is working correctly. If both width and height is defined, the image will scale to fill the area without maintaining the aspect ratio. The documentation is not correct. The test case in the comment should make the image scale keeping the aspect ratio intact and keeping the width. Code change fix this issue https://github.com/appcelerator/titanium_mobile/pull/4738
  7. Hieu Pham 2013-10-13

    CR + FR

JSON Source