1
votes

While developing on Titanium for Android, I need to set the dimensions of a mapview to put on a window, and specifically need to set the mapview's height. Therefore, I need to know what the visible screen size is.

Here's the layout: 1. Tabgroup (whatever size is default for that android device) 2. Mapview (occupy the remaining screen real estate) 3. center icon (to be placed in the middle of the mapview, with fixed size) 4. Label (fixed size) 5. Button (fixed size)

One way is to do this is to get the tabgroup height programmatically, and then substract from platformHeight all the other elements (the tabgroup, the label height, and the button). But I cannot find a way to get the tabgroup height -- does anyone know?

Please note that I cannot just use bottom property on mapview (i.e., set it to label.height + button.height), since I still need to know what the mapview height is so that I can place the center icon in the middle of it.

Any suggestions would be greatly appreciated.

1

1 Answers

1
votes

Generally after an item is rendered you should see valid values in the size property. This will be an object with width and height.

uiobject.size = { width: x, height: x }

If you query the size of objects before they are rendered it will typically return zeroes. By rendered I do not necessarily mean visible on-screen, but placed in a parent view and composed. The object could be hidden/invisible, but as soon as it is laid out these properties should become valid.

This should work for the tab group, the inner map view, etc. Whatever you need to use for reference.

Also, have you tried using the center property for laying this out? This has the same caveats as above (only valid once composed on a parent view), but you should be able to do something like this:

parent.add(mapView);
parent.add(centerIcon);
centerIcon.center = mapView.center;