PROBLEM DESCRIPTION
You have a parent view with height and width set to 'auto'. When you add views to this parent view, you eventually can ask for the current width and height, via the "size" dictionary. In iOS, it's working just fine, you add a child view, and the parent view will get you the right height. That is not working on Android.
STEPS TO REPRODUCE
1. Create a mobile project
2. Paste the code below to the app.js
3. Run in Android.
CODE
var win = Ti.UI.createWindow();
var view = Ti.UI.createView({
height:'auto',
width:'auto'
});
var otherview=Ti.UI.createView({
backgroundColor:'white',
width:100,
height:100,
});
view.add(otherview);
win.add(view);
Ti.API.info("View height:");
Ti.API.info(view.size.height);
win.open();
On Android, dimensions are calculated when window opens, so to get dimensions of some component, you must use window's "open" event.
I'm not sure is this ticket a request for a change of Android's dimension calculation functionality, but I certainly think that this is an issue on Android side.
As Ivan points out, We cannot know the view's dimensions before the view is draw on screen (which is what happens when
win.open()
is called). You'd either need to do this in an open event, or some other time after the view has shown.