Hi there,
I've read all the posts that try to solve this issue with android, but i can't get the size of the working area of the window with any of them.
Most of the posts are based on the 'open' event of the window, but that doesn't work.
This is the code i'm trying:
var mywindow = Ti.UI.createWindow({ }); var viewToCalculateSize = Ti.UI.createView({ }); mywindow.add(viewToCalculateSize); mywindow.addEventListener('open', function(){ alert('window height: ' + viewToCalculateSize.size.height); alert('window width: ' + viewToCalculateSize.size.width); }); mywindow.addEventListener('click', function(){ alert('window height: ' + viewToCalculateSize.size.height); alert('window width: ' + viewToCalculateSize.size.width); }); mywindow.open();The results for this code are 0 values for the 'open' event. That means the view or window is not created yet when the open event triggers. Is there any event that triggers when the window is completely loaded?
The results for the 'click' event are correct, but obviously i can't use that event to retrieve the window size values.
Any other option?
Thanks in advance.
2 Answers
Accepted Answer
You need to add an event listener to the postlayout event. See this thread for more details.
if you want to know the size of a full window then you can get this with Ti.Platform.DisplayCaps.platformWidth and Ti.Platform.DisplayCaps.platformHeight.
Your Answer
Think you can help? Login to answer this question!