{ "id": "146906", "key": "AC-1664", "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": "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": "2015-09-30T01:02:48.000+0000", "created": "2015-04-14T16:00:18.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-10-09T08:35:57.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "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": "Back in the 1.7 days, I could have a view which sized itself automatically to its children's sizes, but I could also add a view as a child which would fill to the calculated parent size. \r\n\r\nIt is very useful for adding a translucent background view to an auto sized view.\r\n\r\nPost 2.0, the logical way to do this would be to specify { width : Ti.UI.SIZE, height: Ti.UI.SIZE } on the parent and then add a child with { width: Ti.UI.FILL, height: Ti.UI.FILL, backgroundColor: 'black', opacity: 0.75 }, followed by whatever views you want the parent to size to. Unfortunately the parent tries to take the size of the auto fill child into account when sizing, which ends up making it the largest possible size it could be. Using the 'postlayout' event is possible to resize it appropriately but it provides an awful user experience as it pops in, rather than just being rendered correctly.\r\n\r\nI poked through the layout code in TiViewProxy.m and made a small change which effectively fixed it for me, though I suspect the child view is probably still sized incorrectly (but it doesn't grow the parent so it looks correct). I changed lines in autoWidthForSize and autoHeightForSize to be like (replace height with width for the other case):\r\n\r\nif (!isAbsolute) {\r\n sandBox = [self computeChildSandbox:thisChildProxy withBounds:bounds];\r\n thisHeight = sandBox.origin.y + sandBox.size.height;\r\n }\r\n else if (![thisChildProxy heightIsAutoFill]) {\r\n\r\nrather than\r\n\r\nif (!isAbsolute) {\r\n sandBox = [self computeChildSandbox:thisChildProxy withBounds:bounds];\r\n thisHeight = sandBox.origin.y + sandBox.size.height;\r\n }\r\n else {\r\n\r\nIt is very easy to reproduce:\r\n\r\n\tvar autoSizeView = Ti.UI.createView({ \r\n\t\theight: Ti.UI.SIZE,\r\n\t\twidth: 200 \r\n\t});\r\n\t\r\n\tvar labelView = Ti.UI.createLabel({\r\n\t\tcolor : 'white',\r\n\t\ttext : 'This is a test\\n of text',\r\n\t\ttextAlign: Ti.UI.TEXT_ALIGNMENT_CENTER\r\n\t});\r\n\t\r\n\tvar bgView = Ti.UI.createView({\r\n\t\tbackgroundColor : 'blue',\r\n\t\topacity: 0.75,\r\n\t\theight : Ti.UI.FILL,\r\n\t\twidth : Ti.UI.FILL\r\n\t});\r\n\r\n\tautoSizeView.add(bgView);\r\n\tautoSizeView.add(labelView);\r\n\t\r\n\twindow.add(autoSizeView);", "attachment": [], "flagged": false, "summary": "Child view with Ti.UI.FILL for a dimension inside of a parent with Ti.UI.SIZE for the same dimension does not work properly", "creator": { "name": "justin@tadpoles.com", "key": "justin@tadpoles.com", "displayName": "Justin Waugh", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "justin@tadpoles.com", "key": "justin@tadpoles.com", "displayName": "Justin Waugh", "active": true, "timeZone": "America/New_York" }, "environment": "iOS", "comment": { "comments": [ { "id": "349927", "author": { "name": "hmrida", "key": "hmrida", "displayName": "Harish Mridha", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hi,\r\nWe have tested this with Titanium SDK version 4.0.0.Beta2 and 3.5.1 GA with CLI 3.4.2 on iOS .\r\nParent view with Ti.UI.SIZE specifies that the view should adjust this size to fit its Child view with Ti.UI.FILL.\r\n\r\n*The height and width properties accept several special values*\r\n{code}\r\n1. Titanium.UI.FILL specifies that the view should fill the parent in this dimension.\r\n2. Titanium.UI.SIZE specifies that the view should adjust this size to fit its contents, such as a label's text or a view's children.\r\n3 .'auto' specifies that the view should choose either FILL or SIZE behavior. In 2.0, the behavior of the 'auto' value is specified by the UI Composite Layout Spec. This value is not recommended for new development and will be deprecated in the future.\r\n{code}\r\n\r\nIts working properly .\r\n*Test Code*\r\n\r\n{code}\r\nvar win = Titanium.UI.createWindow({\r\n\ttitle : 'Test',\r\n});\r\n\r\nvar autoSizeView = Ti.UI.createView({\r\n\theight : Ti.UI.SIZE,\r\n\twidth : 200,\r\n});\r\nvar labelView = Ti.UI.createLabel({\r\n\tcolor : 'white',\r\n\ttext : 'This is a test\\n of text',\r\n\ttextAlign : Ti.UI.TEXT_ALIGNMENT_CENTER\r\n});\r\n\r\nvar bgView = Ti.UI.createView({\r\n\tbackgroundColor : 'blue',\r\n\topacity : 0.75,\r\n\theight : Ti.UI.FILL,\r\n\twidth : Ti.UI.FILL\r\n});\r\nautoSizeView.add(bgView);\r\nautoSizeView.add(labelView);\r\nwin.add(autoSizeView); \r\n\r\nwin.open();\r\n{code}\r\n\r\nThanks", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-04-17T06:27:29.000+0000", "updated": "2015-09-30T01:02:36.000+0000" }, { "id": "428814", "author": { "name": "a.marcone", "key": "a.marcone", "displayName": "Alberto Marcone", "active": true, "timeZone": "Europe/Berlin" }, "body": "I can still reproduce this in 6.2.1, and I stumbled upon this for the past few years as a long time titanium developer (thank goodness I found this ticket!!!). Saying that it's unreproducible is nonsense.\r\n\r\nThis is a sample layout:\r\n\r\n-TableViewRow (height: Ti.UI.SIZE)\r\n--View (height: Ti.UI.SIZE)\r\n--- View (height : Ti.UI.FILL)\r\n--- Label (height : Ti.UI.SIZE)\r\n\r\n The workaround provided by the OP fixed it though. Thank you!", "updateAuthor": { "name": "a.marcone", "key": "a.marcone", "displayName": "Alberto Marcone", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-10-09T08:35:57.000+0000", "updated": "2017-10-09T08:35:57.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }