{ "id": "93964", "key": "AC-2978", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-07-17T09:19:17.000+0000", "created": "2012-06-27T02:19:31.000+0000", "labels": [ "api", "ios" ], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:47:59.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "height / width / size for any view stopped working when it's 'auto','100%',Ti.UI.SIZE.\r\nMy project created and published to AppStore on version - 1.8.0.1. Now I decided to move on to the latest version of 2.0 - 2.1.\r\nI found out that all my animation in my project stopped working.\r\n\r\nIf I set for example:\r\nwin.setHeight('100%')\r\ngetting: win.getHeight() was giving me the exact number (in pixels). Now it returns me '100%'. I can do nothing with this value. I need the number (like it worked before).\r\nI tried to get the size of the device, reducing the status-bar calculation... but it is really a bad idea to support all platforms and devices.\r\n\r\nI guess the idea of getHeight() now is to get the original value set, but before it gave the calculated number, is there a new property to have it now on 2.0? I searched and I didn't find... that's why I think it's a bug.\r\n\r\nBtw, I also tried to check the width/height/size after the window opened and nothing helps.\r\n\r\nIs there a way to fix that bug?", "attachment": [], "flagged": false, "summary": "height / width / size , stooped working on v2.0+", "creator": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "subtasks": [], "reporter": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "environment": "Titanium Mobile 2.0+", "comment": { "comments": [ { "id": "201764", "author": { "name": "btran", "key": "btran", "displayName": "Betty Tran", "active": true, "timeZone": "America/Los_Angeles" }, "body": "To get the height and width of the view if 'auto', '100%', Ti.UI.SIZE or Ti.UI.FILL has been specified, use the size.height and size.width property. Using the postlayout event listener is recommended as the actual height/width is returned after it has been rendered. For example:\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow();\r\nvar view = Ti.UI.createView({\r\n\theight: Ti.UI.FILL,\r\n\twidth: Ti.UI.FILL\r\n});\r\n\r\nwin.add(view);\r\nwin.open();\r\n\r\nview.addEventListener('postlayout', function(e){\r\n\tTi.API.info('Height: ' + view.size.height);\r\n});\r\n\r\n{code}\r\n\r\nThe use of 'auto' is not advised as it will eventually be deprecated. Using Ti.UI.SIZE and Ti.UI.FILL is recommended. For more information on size behavior, please refer to this guide: https://wiki.appcelerator.org/display/guides/Titanium+2.0+Layout+Changes#Titanium2.0LayoutChanges-ViewTypesandDefaultLayoutBehavior. ", "updateAuthor": { "name": "btran", "key": "btran", "displayName": "Betty Tran", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-06T01:48:05.000+0000", "updated": "2012-07-06T01:48:05.000+0000" }, { "id": "202022", "author": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "\r\nIf I need to make animation calculation, I can't do them all in this 'postlayout' event! I'm willing to wait until the window is ready for getting the correct width/height of views, but it's impossible to deal all the needs from this event, it must be accessible anytime from everywhere (like before).\r\n\r\nAnd how come from 'postlayout' the xxx.height will be 234px (for example) and from other area of code it will show the init state '77%'? It's wrong. Why not changing it to a fact that if the layout is ready, anytime I call to Height/Width properties I get it's value and not the init value (100% or whatever)?\r\nI'm sorry but I can't write all my code from 'postlayout' function with lots of \"if\" statements :-(\r\n\r\nAnother thing is that I have a feeling that 'postlayout' event is not fired on time, sometimes it's not firing at all and sometimes it's firing more that once. Strange and not constant behavior.\r\n", "updateAuthor": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2012-07-08T01:29:58.000+0000", "updated": "2012-07-08T01:29:58.000+0000" }, { "id": "202328", "author": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "Betty Tran. your solution is not working if you set the height to (still no values in 'postlayout' event function):\r\n\r\nheight: '30%' // <-- AS I NEED IT\r\n\r\n(instead of what you did --> height: Ti.UI.FILL)", "updateAuthor": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2012-07-10T05:50:58.000+0000", "updated": "2012-07-10T05:50:58.000+0000" }, { "id": "208054", "author": { "name": "btran", "key": "btran", "displayName": "Betty Tran", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Setting the height to '30%' still yields the correct actual size.height value in the postlayout event. The height and width properties return the dimensions in platform units, which are the initial values declared. The size.height and size.width properties return the dimensions in system units. This is expected behavior as outlined in the documentation (http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.UI.View-property-size).", "updateAuthor": { "name": "btran", "key": "btran", "displayName": "Betty Tran", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-17T08:55:07.000+0000", "updated": "2012-07-17T08:55:07.000+0000" }, { "id": "213074", "author": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "\r\nI played a lot with this new \"postlayout\" event... and I can tell you one thing I noticed:\r\nIT IS NOT GOOD ENOUGH !!!\r\n\r\nIt has many problems, impossible to code inside, too many tweaks knowing if it's the first time because it fires sometimes too much... and the most important: NO SUPPORT FOR WINDOW !!!!!!!!!\r\nI attach a handler to the main window (because I want the window sizes - excluding the \"statusbar\" for example) and I get millions of events for each view on the page!\r\n\r\nI just want to know the width/height of my window, before I show the window, I want to draw/place views on this window regarding it's sizes!!!\r\nIT WORKED ON 1.8, WHY DID IT STOPPED ??? I am stack on version 1.8 and can not move forward to 2.1 only because there are too many things that simply STOPPED working :-(\r\n", "updateAuthor": { "name": "mry", "key": "mry", "displayName": "Yoram", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2012-08-07T00:46:10.000+0000", "updated": "2012-08-07T00:46:10.000+0000" }, { "id": "213993", "author": { "name": "btran", "key": "btran", "displayName": "Betty Tran", "active": true, "timeZone": "America/Los_Angeles" }, "body": "A workaround to obtain the window size without the status bar is to get the size property on window open. For example:\r\n\r\n{code}\r\nwin.addEventListener('open', function(e){\r\n\talert(\"Height: \" + win.size.height + \" Width: \" + win.size.width);\r\n});\r\n{code}\r\n\r\n\r\nIt was removed after 1.8 for performance reasons.\r\n", "updateAuthor": { "name": "btran", "key": "btran", "displayName": "Betty Tran", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-13T07:21:45.000+0000", "updated": "2012-08-13T07:21:45.000+0000" }, { "id": "286238", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello,\r\n\r\nI tested this issue with the test code bellow. It’s working good in android/iOS. Device size, view height and width are getting perfectly.\r\n \r\n \r\nh5. Testing Environment:\r\n\r\nTitanium SDK: 3.2.0,\r\nTitanium CLI: 3.2.0,\r\nAndroid SDK: 4.2.2\r\n \r\n \r\nh5. Steps to Reproduce:\r\n# Create a sample project.\r\n# Paste this code in app.js file.\r\n# Run this code with testing environment.\r\n \r\n h5. Test Code\r\n{code}\r\n \r\nvar win = Ti.UI.createWindow();\r\n \r\nvar view = Ti.UI.createView({\r\n height: '60%',\r\n width: Ti.UI.FILL\r\n});\r\nwin.add(view);\r\n \r\nwin.addEventListener('open', function(e) {\r\n\talert(\"Height: \" + view.size.height + \" Width: \" + view.size.width);\r\n});\r\n \r\nvar a = Ti.Platform.displayCaps.platformHeight;\r\nvar b = Ti.Platform.displayCaps.platformWidth;\r\n \r\nvar sizeWin = Titanium.UI.createLabel({\r\n\ttext : 'display width-x-height:' + b + 'x' + a,\r\n\ttop : 2,\r\n\tleft : 10,\r\n\twidth : 300,\r\n\theight : 'auto',\r\n\tfont : {\r\n\t\tfontSize : 20\r\n\t},\r\n\tcolor : '#777'\r\n});\r\nview.add(sizeWin);\r\nwin.open();\r\n\r\n{code}\r\n\r\n\r\nThanks \r\n\r\n", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-12-30T10:39:40.000+0000", "updated": "2013-12-30T19:22:40.000+0000" }, { "id": "286286", "author": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Marking this closed since we can't reproduce it in our latest versions of the TISDK. We posted a sample to validate our test results.", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-12-30T19:23:21.000+0000", "updated": "2013-12-30T19:23:21.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }