{ "id": "91413", "key": "TIMOB-9121", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2013-06-19T18:36:02.000+0000", "created": "2012-05-06T11:38:42.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "api", "exalture", "parity" ], "versions": [ { "id": "13272", "description": "Release 2.0.1", "name": "Release 2.0.1", "archived": true, "released": true, "releaseDate": "2012-04-16" } ], "issuelinks": [], "assignee": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "updated": "2017-03-21T21:31:18.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h6.Issue\r\nWhenever label.toImage().height is used in Android it always returns 100 no matter how large the label field is.\r\n \r\nTried converting an auto sized label to and image to get the height of it to figure out what size table I need to hold all of them. \r\n\r\nh6.Expected outputs\r\nEach label has its own height (as seen in iOS simulator)\r\n\r\nh6.Actual outputs\r\nBoth height = 100\r\n\r\nh6.Tested on\r\nLG ally 2.2 & Droid razr 2.3.5\r\n\r\nh6.Repro sequence\r\n- app.js\r\n{code}\r\n// this sets the background color of the master UIView (when there are no windows/tab groups on it)\r\nTitanium.UI.setBackgroundColor('#000');\r\n\r\n\r\n//\r\n// create base UI tab and root window\r\n//\r\nvar win1 = Titanium.UI.createWindow({ \r\n title:'Tab 1',\r\n backgroundColor:'#fff',\r\n layout:'vertical'\r\n});\r\n\r\nvar label1 = Titanium.UI.createLabel({\r\n\tcolor:'#999',\r\n\ttext:'Short Label',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\twidth:'auto',\r\n\ttop:0\r\n});\r\n\r\nvar label1Size = label1.toImage().height;\r\n\r\nwin1.add(label1);\r\n\r\nvar label1Sizeinfo = Ti.UI.createLabel({\r\n\ttext:'The size of label 1 is ' + label1Size,\r\n\ttop:0\r\n});\r\n\r\nwin1.add(label1Sizeinfo);\r\n\r\n\r\nvar label2 = Titanium.UI.createLabel({\r\n\tcolor:'#999',\r\n\ttext:'Earlier today, Fearless Leader announced Appcelerator's plans to support native application development for the BlackBerry 10. Work is already underway to implement the Titanium JavaScript API on BlackBerry 10 devices using BlackBerry's NDK. Unlike previous versions of the BlackBerry...',\r\n\tfont:{fontSize:20,fontFamily:'Helvetica Neue'},\r\n\twidth:'auto',\r\n\ttop:0\r\n});\r\n\r\nvar label2Size = label2.toImage().height;\r\n\r\nwin1.add(label2);\r\n\r\nvar label2Sizeinfo = Ti.UI.createLabel({\r\n\ttext:'The size of label 2 is ' + label2Size,\r\n\ttop:0\r\n});\r\n\r\nwin1.add(label2Sizeinfo);\r\n\r\nwin1.open();\r\n{code}\r\n\r\n", "attachment": [ { "id": "27670", "filename": "iOS_Labels.jpg", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-05-11T20:49:47.000+0000", "size": 39847, "mimeType": "image/jpeg" } ], "flagged": false, "summary": "Android: label.toImage().height not working correctly ", "creator": { "name": "csmashe", "key": "csmashe", "displayName": "chris smashe", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "csmashe", "key": "csmashe", "displayName": "chris smashe", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK 2.0.1.GA2\r\nAndroid OS 2.2 & 2.3", "comment": { "comments": [ { "id": "194219", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "The test case is invalid due to doesn't set height value for any of label1 & label2 (that's why it renders same values in this case 100).\r\n\r\nSee refined sample that calculates height per each label:\r\n\r\nh6.Repro sequence\r\n- app.js\r\n{code}\r\n// this sets the background color of the master UIView (when there are no windows/tab groups on it)\r\nTitanium.UI.setBackgroundColor('#000');\r\n\r\n//\r\n// create base UI tab and root window\r\n//\r\nvar win1 = Titanium.UI.createWindow({\r\n\ttitle : 'Tab 1',\r\n\tbackgroundColor : '#fff',\r\n\tlayout : 'vertical',\r\n\theight: 'auto'\r\n});\r\n\r\nvar label1 = Titanium.UI.createLabel({\r\n\tcolor : '#999',\r\n\ttext : 'Short Label',\r\n\tfont : {\r\n\t\tfontSize : 20,\r\n\t\tfontFamily : 'Helvetica Neue'\r\n\t},\r\n\twidth : 'auto',\r\n\theight: 'auto',\r\n\ttop : 0\r\n});\r\n\r\nvar label1Size = label1.toImage().height;\r\nTi.API.info(' >>>>>>>>>>> label1Size: '+ label1Size);\r\n\r\nwin1.add(label1);\r\n\r\nvar label1Sizeinfo = Ti.UI.createLabel({\r\n\ttext : 'The size of label 1 is ' + label1Size,\r\n\ttop : 0\r\n});\r\n\r\nwin1.add(label1Sizeinfo);\r\n\r\nvar label2 = Titanium.UI.createLabel({\r\n\tcolor : '#999',\r\n\ttext : 'Earlier today, Fearless Leader announced Appcelerators plans to support native application development for the BlackBerry 10. Work is already underway to implement the Titanium JavaScript API on BlackBerry 10 devices using BlackBerrys NDK. Unlike previous versions of the BlackBerry...',\r\n\tfont : {\r\n\t\tfontSize : 20,\r\n\t\tfontFamily : 'Helvetica Neue'\r\n\t},\r\n\twidth : 'auto',\r\n\theight: Ti.UI.SIZE,\r\n\ttop : 0\r\n});\r\n\r\nvar label2Size = label2.toImage().height;\r\nTi.API.info(' >>>>>>>>>>> label2Size: '+ label2Size);\r\n\r\nwin1.add(label2);\r\n\r\nvar label2Sizeinfo = Ti.UI.createLabel({\r\n\ttext : 'The size of label 2 is ' + label2Size,\r\n\ttop : 0\r\n});\r\n\r\nwin1.add(label2Sizeinfo);\r\n\r\nwin1.open();\r\n{code}\r\n\r\nh6.As per the sample provided that might return:\r\n{code}\r\nThe size of label 1 is 27\r\nThe size of label 2 is 100\r\n{code}\r\n\r\nClosing at this time Jira ticket. If there are further issues please provide *target environment* and what is the device or emulator this was tested on.", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-05-08T20:51:52.000+0000", "updated": "2012-05-08T20:51:52.000+0000" }, { "id": "194507", "author": { "name": "csmashe", "key": "csmashe", "displayName": "chris smashe", "active": true, "timeZone": "America/Los_Angeles" }, "body": "You said \r\n??The test case is invalid due to doesn't set height value for any of label1 & label2 (that's why it renders same values in this case 100).??\r\n\r\nAccording to your documentation [http://docs.appcelerator.com/titanium/2.0/index.html#!/guide/Transitioning_to_the_New_UI_Layout_System] it says\r\n\r\n??When width or height parameters are undefined, an attempt will be made to calculate these parameters implicitly. If they cannot be calculated implicitly, they will follow \"auto\" behavior. In previous versions of the Titanium SDK undefined width or height enforced FILL behavior.??\r\nwhich should mean that it blank is the same as auto right?\r\n\r\nUsing your example above if you change 40 from \r\n{code}\r\n text : 'Earlier today, Fearless Leader announced Appcelerators plans to support native application development for the BlackBerry 10. Work is already underway to implement the Titanium JavaScript API on BlackBerry 10 devices using BlackBerrys NDK. Unlike previous versions of the BlackBerry...',\r\n {code}\r\nto *I doubled the amount of text*\r\n{code}\r\n text : 'Earlier today, Fearless Leader announced Appcelerators plans to support native application development for the BlackBerry 10. Work is already underway to implement the Titanium JavaScript API on BlackBerry 10 devices using BlackBerrys NDK. Unlike previous versions of the BlackBerry...Earlier today, Fearless Leader announced Appcelerators plans to support native application development for the BlackBerry 10. Work is already underway to implement the Titanium JavaScript API on BlackBerry 10 devices using BlackBerrys NDK. Unlike previous versions of the BlackBerry...',\r\n {code}\r\nThe size of the label should be 200. It is still 100.\r\n\r\nAfter further investigation if i change line 46 from\r\n{code}\r\nheight: Ti.UI.SIZE,\r\n{code}\r\nto \r\n{code}\r\nheight: 'auto'\r\n{code}\r\n\r\nto mimic label number 1 where you use auto instead of the new Ti.UI.SIZE the size of the label changes from 100 to 27 which is the same as label 1. According to your documentation referenced above \r\n\r\n??specifying 'auto' for either height or width is the same as specifying Ti.UI.SIZE. ?? \r\n Since auto is returning 100 and Ti.UI.SIZE is returning 27 this seems to not be the case.\r\n\r\nTo recap everything that has been found to be wrong.\r\n\r\n1. label2.toImage().height is not giving the correct height in android. it is returning 27 if you use Ti.UI.SIZE for the height and 100 if you use auto no matter how much text is actually in the label.\r\n2. Ti.UI.SIZE and auto are not returning the same height so specifying 'auto' for either height or width is *Not* the same as specifying Ti.UI.SIZE\r\n\r\nThis has been tested in the following set ups all with the same result\r\nAndroid Emulator \r\nMotorola Droid\r\nHTC Droid Incredible. \r\n", "updateAuthor": { "name": "csmashe", "key": "csmashe", "displayName": "chris smashe", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-05-11T08:22:19.000+0000", "updated": "2012-05-11T08:22:19.000+0000" }, { "id": "194610", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-05-11T20:51:40.000+0000", "updated": "2012-05-11T20:51:40.000+0000" }, { "id": "195362", "author": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Seeing this as well. Note that on iOS (and in the docs) toImage returns a Blob. On Android, it appears to return a dictionary containing {{height}}, {{width}}, {{cropRect}}, and the actual blob ({{media}}).\r\n\r\nThe size appears to be incorrect on the blob, as well, however. media.height and media.width are both returning 0, and the image is a black square. So it doesn't appear that toImage is working at all, at least on emulator.\r\n\r\nI believe this is all because the view (label in this case) isn't fully laid out when {{toImage}} is called.\r\n\r\nHowever, for this use case, toImage is overkill, anyway. The appropriate way to handle this would be to listen for the postlayout event and checking label.size.height:\r\n\r\nlabel.addEventListener('postlayout', function(e) {\r\n\tTi.API.info(\"label height = \"+ button.size.height);\r\n})\r\n", "updateAuthor": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-05-18T18:20:50.000+0000", "updated": "2012-05-18T18:20:50.000+0000" }, { "id": "195374", "author": { "name": "csmashe", "key": "csmashe", "displayName": "chris smashe", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The test case was just to show it not working. The height is being used to add set the height of the rows and table that the label is in when you are using dynamic data since you can not just set everything to auto and have it grow and shrink based on the amount of text. ", "updateAuthor": { "name": "csmashe", "key": "csmashe", "displayName": "chris smashe", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-05-19T11:35:45.000+0000", "updated": "2012-05-19T11:35:45.000+0000" }, { "id": "197957", "author": { "name": "csmashe", "key": "csmashe", "displayName": "chris smashe", "active": true, "timeZone": "America/Los_Angeles" }, "body": "How long does it take to have bugs in the sdk looked at?\r\n", "updateAuthor": { "name": "csmashe", "key": "csmashe", "displayName": "chris smashe", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-06-10T07:03:07.000+0000", "updated": "2012-06-10T07:03:07.000+0000" }, { "id": "258581", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "I can't reproduce this. Both samples gives the consistent output for both labels as 28. Tried with 3.2 in Nexus S.", "updateAuthor": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-06-19T18:36:02.000+0000", "updated": "2013-06-19T18:36:02.000+0000" }, { "id": "414458", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as the issue cannot be reproduced.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-21T21:31:18.000+0000", "updated": "2017-03-21T21:31:18.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }