{ "id": "63870", "key": "TIMOB-3238", "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": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-01-10T11:49:07.000+0000", "created": "2011-04-15T03:40:09.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "module_views", "qe-testadded" ], "versions": [ { "id": "11233", "name": "Release 1.6.0", "archived": true, "released": true, "releaseDate": "2011-02-23" } ], "issuelinks": [ { "id": "14724", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "85327", "key": "TIMOB-7344", "fields": { "summary": "iOS: Views - Nested view cannot be displayed when dimension property is defined using percentage", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-11-07T05:46:28.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": "I'm using latest Titanium mobile (1.6.1) and Android emulator (Galaxy Tab addon 2.2). I have problem with dimensions defined as\r\npercentage when I put view in another view. Here is test case:\r\n\r\n{code:lang=javascript|title=app.js}\r\n var win = Ti.UI.createWindow({\r\n layout: 'vertical', \r\n fullscreen: true, \r\n height : Ti.Platform.displayCaps.platformHeight,\r\n width : Ti.Platform.displayCaps.platformWidth\r\n});\r\n\r\nvar view = Ti.UI.createView({\r\n layout: 'horizontal',\r\n height: 50,\r\n backgroundColor: '#ccf',\r\n width: '50%'\r\n});\r\nvar nested_view = Ti.UI.createView({\r\n height: 50,\r\n backgroundColor: '#cfc',\r\n width: '50%'\r\n});\r\n\r\nview.add(nested_view);\r\nwin.add(view);\r\nwin.open();\r\n{code}\r\n\r\nSecond view, \"nested_view\", doesn't show at all, but I think it should and it should have half of \"view\" width.\r\n", "attachment": [ { "id": "24797", "filename": "screenshot_458.png", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-21T02:53:04.000+0000", "size": 8641, "mimeType": "image/png" } ], "flagged": false, "summary": "Android: UI - A problem with dimensions defined as percentage in nested views", "creator": { "name": "ivanskugor", "key": "ivanskugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "ivanskugor", "key": "ivanskugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "130351", "author": { "name": "ivanskugor", "key": "ivanskugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}
Same problem applies to TableView. I haven't checked for other\n\"views\".
I'm also having the same problem as Ivan. With the following\ncode I am unable to see the viewInputs view. This is the case even\nis viewInputs contains other components as well.
\nvar win = Titanium.UI.createWindow();
\nwin.backgroundColor = '#dddddd';
\nwin.layout = 'vertical';
var viewTop = Titanium.UI.createView({
\nborderRadius:10, backgroundColor:'#ffffff', borderColor:'#000000',\nborderWidth:2, width:'95%', height:'20%', top:'2.5%',\nlayout:'horizontal' }); win.add(viewTop);
var viewInputs = Titanium.UI.createView({
\nwidth:'50%',\nheight:'100px',\nbackgroundColor:'#ff0000',\ntop:5,\nleft:5,\nlayout:'vertical'
\n
\n}); viewTop.add(viewInputs);
\nwin.open();
I am having same issue with Ti Mobile 1.6.1 and Android 1.6\nattempting percentage width on a view (just plain view).
To calculate percentage dimensions one can:
\n\nvar width = Math.round(Ti.Platform.displayCaps.platformWidth*0.9); // 90%\nvar height = Math.round(Ti.Platform.displayCaps.platformHeight*0.9); // 90%
\n
\nSource: Appcelerator\nQ&A
That works for elements which parent element has\n\"Ti.Platform.displayCaps.platformWidth\" width.
\nIn general, parent's width/height can be whatever, percentages\nare there so you don't need to calculate it manually, they are\ncalculated automatically depending on parent element size.
Dimensions calculated like Joe iEntry suggests don't get\nrecalculated on orientation change. Dimensions specified with a\npercentage value do. This is a major problem for me in my current\nproject. I can't get horizontal layouts to work with percentage\ndimensions (iPad if that matters). Instead I'm using hacks and\ncustom code to do something pretty basic.
What's going on here?
I understand this is not meant for discussion, but Tony, I\nhaven't tested my app with orientation change. This will be a must.\nCan you post your workaround?
I don't have code I can post right now, but the idea is to set\ndimensions like this (similar to how you stated above):
\nchild.width = parent.width * 0.5;
\nKeep a reference to this child in an array, and then resize it\nin a Titanium.Gesture.orientationchange event handler. It sucks,\nbut it works.