{ "id": "62407", "key": "TIMOB-1775", "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": "11225", "name": "Release 1.5.0", "archived": true, "released": true, "releaseDate": "2010-12-14" } ], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2018-08-02T22:06:32.000+0000", "created": "2011-04-15T03:01:56.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "android", "apidoc", "center", "feature", "missing", "patch", "properties", "ui", "ui.view", "view" ], "versions": [], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-08-02T22:06:38.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}

Docs for Ti.UI.View and its fellow view types lists a center\nproperty:

\n

\nhttps://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI...

\n
\ncenter   object      a dictionary with properties x and y to indicate the center of the views position relative to the parent view\n
\n

This property is very useful for positioning things under, over,\nor next to other views, however it appears to be unimplemented on\nAndroid.

\n
\n/*\n * This code demonstrates the missing center property on Android...\n * on iPhone shows: \"160, 230\"\n * on Android shows: \"wtf? null\"\n */\n\nvar window = Titanium.UI.createWindow({\n});\nvar button = Titanium.UI.createButton({\n    title: \"Where am I?\",\n    width: 200,\n    height: 50\n});\nbutton.addEventListener('click', function() {\n    var center = button.center;\n    var msg;\n    Ti.API.info('center: ' + center);\n    if (center) {\n        Ti.API.info('center.x: ' + center.x);\n        Ti.API.info('center.y: ' + center.y);\n        msg = center.x + ', ' + center.y;\n    } else {\n        msg = 'wtf? ' + center;\n    }\n    button.title = msg;\n});\nwindow.add(button);\nwindow.open();\n
\n

Changing it to check an actual 'View' object makes no\ndifference; View, Button, and Label have all been tested, and\nthere's no sign of a 'center' property implementation in the\ntitanium_mobile/android source tree.

{html}", "attachment": [], "flagged": false, "summary": "Ti.UI.View center property not implemented on Android, no warning in documentation", "creator": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "rpfeiffer", "key": "rpfeiffer", "displayName": "Ralf Pfeiffer", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "closedSprints": [ { "id": 1058, "state": "closed", "name": "2018 Sprint 16 SDK", "startDate": "2018-07-29T22:26:06.486Z", "endDate": "2018-08-12T22:26:00.000Z", "completeDate": "2018-08-13T17:38:16.757Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "126628", "author": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I've implemented a getter, it seems to work for me:

\n

http://github.com/brion/titanium_mobile/commits/android-center
\n\nhttp://github.com/brion/titanium_mobile/commit/f0c7f7d64f0d58ded647...

{html}", "updateAuthor": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:57.000+0000", "updated": "2011-04-15T03:01:57.000+0000" }, { "id": "126629", "author": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Assigning to Don for review per IRC.

{html}", "updateAuthor": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:57.000+0000", "updated": "2011-04-15T03:01:57.000+0000" }, { "id": "126630", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [5c491f17f7d9592942ae24af18ac4a494ccfee4b])\n[#1775 state:fixed-in-qa] Implement getter for\nView.center property on Android \nhttp://github.com/appcelerator/titanium_mobile/commit/5c491f17f7d95...

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:58.000+0000", "updated": "2011-04-15T03:01:58.000+0000" }, { "id": "126631", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

1.6 G1, 2.2 simulator. iOS 4.1 and 3.2.2. 1.4.1.ec5d6d

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:58.000+0000", "updated": "2011-04-15T03:01:58.000+0000" }, { "id": "185903", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Reopening for parity.\r\n\r\nIn both iOS and Android the following works:\r\n{code}\r\nview.center = { x: 100, y: 100 };\r\n{code}\r\n\r\nBut this only works on iOS and break on Android:\r\n{code}\r\nview.setCenter({x: 100, y: 100});\r\n{code}\r\n\r\n\r\nEdit:\r\n\r\nTested on the latest Titanium 2.0.0 (2012/03/10 10:33 018abda) SDK", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-03-11T10:11:07.000+0000", "updated": "2012-03-11T10:17:36.000+0000" }, { "id": "439714", "author": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "body": "With slightly modified code (since the property starts as \"undefined\" and only reads once set:\r\n{code}\r\nvar window = Titanium.UI.createWindow({\r\n});\r\nvar button = Titanium.UI.createButton({\r\ntitle: \"Where am I?\",\r\nwidth: 200,\r\nheight: 50\r\n});\r\nbutton.addEventListener('click', function() {\r\nbutton.center = {x: 17,y: 19};\r\nvar center = button.center;\r\nvar msg;\r\nTi.API.info('center: ' + center);\r\n \r\n \r\nif (center) { Ti.API.info('center.x: ' + center.x); Ti.API.info('center.y: ' + center.y); msg = center.x + ', ' + center.y; } else { msg = 'wtf? ' + center; }\r\nbutton.title = msg;\r\n});\r\nwindow.add(button);\r\nwindow.open();\r\n{code}\r\n\r\nThe setting of center moves the item, and the console output shows the values as expected on Android:\r\n{code}\r\n[INFO] center.x: 17\r\n[INFO] center.y: 19\r\n{code}\r\n\r\nUnless I am misunderstanding, I am closing as invalid. Please reopen if I am mistaken.", "updateAuthor": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-02T22:06:04.000+0000", "updated": "2018-08-02T22:06:04.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }