[TIMOB-3178] Android: Window dimensions unavailable directly after opening
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Low |
| Status | Closed |
| Resolution | Invalid |
| Resolution Date | 2014-01-07T22:34:33.000+0000 |
| Affected Version/s | Release 3.0.0 |
| Fix Version/s | n/a |
| Components | Android |
| Labels | api |
| Reporter | Bill Dawson |
| Assignee | Biju pm |
| Created | 2011-04-15T03:38:52.000+0000 |
| Updated | 2017-03-20T18:04:17.000+0000 |
Description
The following code used to work (1.5.X):
var win =Ti.UI.createWindow({backgroundColor:'black'});
win.open();
var width = win.width; // Returns 0 since 1.6, used to work in 1.5
Tested on a Samsung Galaxy S2 using TiSDK 2.2.0v20120830102513, issue still valid.
var win = Ti.UI.createWindow({backgroundColor: 'white'}); win.addEventListener('click', function(e) { alert('width: ' + win.width); }); win.open();PR :- https://github.com/appcelerator/titanium_mobile/pull/5171
There's already a size property that does this. Simply use win.size.width or win.size.height to retrieve the width and height of the window.
Closing ticket as invalid.