Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1927] [ios] imageview: resizing with Ti.UI.SIZE when image size ratio != 1

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionWon't Fix
Resolution Date2012-08-15T12:41:12.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsautosize, imageview
ReporterMartin Guillon
AssigneeMauro Parra-Miranda
Created2012-08-14T07:45:02.000+0000
Updated2016-03-08T07:40:51.000+0000

Description

If you fix only height(or width), and rely on Ti.UI.SIZE for the other. Then you will end up with an imageView of height you wanted but of the width of the source image.
var win = Titanium.UI.currentWindow;

var imageView = Titanium.UI.createImageView({
	top:50,
	left:10,
	height:40,
	backgroundColor:'red',
	width:Ti.UI.SIZE
});
win.add(imageView);

var xhr = Titanium.Network.createHTTPClient();

xhr.onload = function()
{
	imageView.image = this.responseData;
};
xhr.open('GET','http://www.maclife.com/files/u53/clouds.jpg');

xhr.send();

pull request coming

Comments

  1. Martin Guillon 2012-08-14

    pull request https://github.com/appcelerator/titanium_mobile/pull/2739
  2. Max Stepanov 2012-08-15

    Implementing requested behavior will break existing [layout specification| http://docs.appcelerator.com/titanium/2.1/index.html#!/guide/UI_Composite_Layout_Behavior_Spec]. According to "Precedence of layoutParams" section, width always has precedence other any other layout values.
  3. Martin Guillon 2012-08-15

    You are right. Are you ok if i add a test
       if (TiDimensionIsAuto(width) || TiDimensionIsAutoSize(width))
       
    Cause in that case (which was my case), it should do that.

JSON Source