{ "id": "63406", "key": "TIMOB-2774", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": "11237", "name": "Release 1.6.0 M04", "archived": true, "released": true, "releaseDate": "2011-01-10" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T02:00:03.000+0000", "created": "2011-04-15T03:29:11.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "enterprise", "feature", "release-1.6.0", "rplist" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T02:00:03.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": "{html}
See attached video for comparison demo.
\n\nvar win = Ti.UI.createWindow({\n navBarHidden:true,\n exitOnClose:true,\n backgroundColor: '#fff'\n});\n\nvar view = Ti.UI.createView({\n // initial setting of of a small box view that is centered\n width: 10,\n height: 10,\n center: {\n x: Ti.Platform.displayCaps.platformWidth / 2,\n y: Ti.Platform.displayCaps.platformHeight / 2\n },\n backgroundColor: '#f00'\n});\n\nvar openBtn = Ti.UI.createButton({\n left: 10,\n right: 10,\n height: 50,\n title: 'Open'\n});\n\nopenBtn.addEventListener('click', function(e) {\n var closeBtn = Ti.UI.createButton({\n left: 10,\n right: 10,\n height: 50,\n title: 'Close'\n });\n\n closeBtn.addEventListener('click', function(e) {\n view.remove(closeBtn);\n\n view.animate({\n center: {\n x: Ti.Platform.displayCaps.platformWidth / 2,\n y: Ti.Platform.displayCaps.platformHeight / 2\n },\n width: 10,\n height: 10,\n duration: 300\n },\n function(e) {\n win.remove(view);\n Ti.API.info('This is going to be called multiple times.');\n });\n });\n\n win.add(view);\n\n // animate small, centered box\n view.animate({\n center: {\n x: Ti.Platform.displayCaps.platformWidth / 2,\n y: Ti.Platform.displayCaps.platformHeight / 2\n },\n width: Ti.Platform.displayCaps.platformWidth,\n height: Ti.Platform.displayCaps.platformHeight,\n duration: 300\n },\n function(e) {\n view.add(closeBtn);\n Ti.API.info('This is going to be called multiple times.');\n });\n});\n\nwin.add(openBtn);\nwin.open();
\n
the \"center\" property wasn't implemented before a few days ago.\nIf you want a truly centered view shouldn't you be using center: {\nx: 0, y: 0 } ? Dividing platformHeight/platformWidth by two would\nbe good for top and left, but not center x/y?
I suppose this has to do with expectation. Is the view centered\nrelative to it's parent and where is the parent's coordinate\norigin?
\nIn a layout tool, if the origin starts in the upper left (0,0),\nthen the relative position of the element positioned on top would\nbe width/2, height/2.
\nOriginally, this worked on both iOS and Android (as seen in\nvideo) as relative to the parents origin at (0,0), upper-left.
\nScreenshot one: Where is it?
\nScreenshot two: How 0,0 works on iOS
Ahh.. I guess I was under the impression that \"center\" was\nrelative to the parent's center position. This never actually\n\"worked\" in Android because the center property wasn't even\nimplemented until a few days ago, so my guess is the values you had\nwere incidental with some of our default behaviors :)
(from [eecab83e319ad70b79af913fbc3ad0d99f8265bc])\ncenter positions are parent-relative to 0,0 instead of\nparent-center relative [#2774 state:fixed-in-qa]
\n\nhttps://github.com/appcelerator/titanium_mobile/commit/eecab83e319a...