Reputation: 7161
This may seem a strange question, but when developing for more than one platform in Appcelerator Titanium, it would be really handy to know where the elements end, since the devices have diferent sizes.
So, is there possible to know where an object starts and ends? For instance, I have a grouped table view, and beneath it I have a map that I want to use all the available space remaining beneath the grouped tableView. How do I do this?
I tried the following:
var winDetailView = Titanium.UI.currentWindow;
var tableDetailRowData = getDetailData();
var tableDetailView = Ti.UI.createTableView({
headerTitle:'Object',
style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
backgroundColor:'transparent',
data:tableDetailRowData,
height : Ti.UI.SIZE,
});
winDetailView.add(tableDetailView);
var mapView = Ti.Map.createView({
top : 200, // this is approximately where my table ends (is there a way to know the exact place?)
left : "10%",
height : "90%", // this doesn't work, since it uses 90% of the device height pixels, not 90% of the remaining pixels below the top property
width : "90%",
mapType : Ti.Map.STANDARD_TYPE,
})
But this doesn't do the trick. Any ideas?
Update:
The getSize()
property seems to work with some objects. Unfortunately with a Grouped tableView the returned size is almost all of the screen, so it's not giving the necessary dimensions.
Upvotes: 0
Views: 262
Reputation: 1089
jbssm,
You can try the following to achieve what you want:
1.Define the layout of the window or parent view(of tableView and mapView)
'layout':'vertical'
2.Give the tableView an height of Titanium.UI.SIZE(height:Titanium.UI.SIZE). This means that the table view will take the minimum space required to show all the contents.
3.In the top of mapView write '10dp' or '20dp' whatever your desired top is.
The trick here is that you have set the layout:vertical.Top of each view in such a parent view is with respect to the one above it.So if you specify '5dp' it will be with respect to the bottom of the view just above it and not from the top of the window.So in this case the top of mapView will be calculated from the bottom of the tableView.
Upvotes: 1