[TIMOB-1775] Ti.UI.View center property not implemented on Android, no warning in documentation
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Trivial |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2018-08-02T22:06:32.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.5.0 |
Components | Android |
Labels | android, apidoc, center, feature, missing, patch, properties, ui, ui.view, view |
Reporter | Ralf Pfeiffer |
Assignee | Eric Merriman |
Created | 2011-04-15T03:01:56.000+0000 |
Updated | 2018-08-02T22:06:38.000+0000 |
Description
Docs for Ti.UI.View and its fellow view types lists a center property:
https://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.View-object"> https://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI...
center object a dictionary with properties x and y to indicate the center of the views position relative to the parent view
This property is very useful for positioning things under, over, or next to other views, however it appears to be unimplemented on Android.
/*
* This code demonstrates the missing center property on Android...
* on iPhone shows: "160, 230"
* on Android shows: "wtf? null"
*/
var window = Titanium.UI.createWindow({
});
var button = Titanium.UI.createButton({
title: "Where am I?",
width: 200,
height: 50
});
button.addEventListener('click', function() {
var center = button.center;
var msg;
Ti.API.info('center: ' + center);
if (center) {
Ti.API.info('center.x: ' + center.x);
Ti.API.info('center.y: ' + center.y);
msg = center.x + ', ' + center.y;
} else {
msg = 'wtf? ' + center;
}
button.title = msg;
});
window.add(button);
window.open();
Changing it to check an actual 'View' object makes no difference; View, Button, and Label have all been tested, and there's no sign of a 'center' property implementation in the titanium_mobile/android source tree.
I've implemented a getter, it seems to work for me:
http://github.com/brion/titanium_mobile/commits/android-center">http://github.com/brion/titanium_mobile/commits/android-center
http://github.com/brion/titanium_mobile/commit/f0c7f7d64f0d58ded647db21a9198a1eb105d830"> http://github.com/brion/titanium_mobile/commit/f0c7f7d64f0d58ded647...
Assigning to Don for review per IRC.
(from [5c491f17f7d9592942ae24af18ac4a494ccfee4b]) [#1775 state:fixed-in-qa] Implement getter for View.center property on Android http://github.com/appcelerator/titanium_mobile/commit/5c491f17f7d9592942ae24af18ac4a494ccfee4b"> http://github.com/appcelerator/titanium_mobile/commit/5c491f17f7d95...
1.6 G1, 2.2 simulator. iOS 4.1 and 3.2.2. 1.4.1.ec5d6d
Reopening for parity. In both iOS and Android the following works:
But this only works on iOS and break on Android:
Edit: Tested on the latest Titanium 2.0.0 (2012/03/10 10:33 018abda) SDK
With slightly modified code (since the property starts as "undefined" and only reads once set:
The setting of center moves the item, and the console output shows the values as expected on Android:
Unless I am misunderstanding, I am closing as invalid. Please reopen if I am mistaken.