var win = Ti.UI.createWindow();
var view = Ti.UI.createView({
backgroundColor : '#336699',
borderRadius : 10,
width : 300,
height : 2000,
top : 10
});
var label2 = Ti.UI.createLabel({
text : 'View Size is: ',
top : 20,
left : 10,
height : 200,
color : 'black'
});
var scrollView2 = Titanium.UI.createScrollView({
contentHeight : 'auto',
contentWidth : 'auto',
showVerticalScrollIndicator : true,
showHorizontalScrollIndicator : true
});
scrollView2.add(view);
label2.add(scrollView2);
win.addEventListener('click', function() {
Ti.API.info("########################" + scrollView2.size.height);
Ti.API.info("########################" + scrollView2.size.width);
});
win.add(label2);
win.open();
The scroll view is not shown, and when you click on the window, the height and width returns 0.
IMHO, this should be marked as invalid. Adding scroll view to a label is something like adding "div" to "label" in DOM world (a crazy thing to do that wouldn't do what you would expect). The problem is that label has "add" method (but it is not container and can't contain other components), which leads to confusion (other controls have that method also, it is documented, but it does nothing). I actually suggested that all UI components should be hierarchically ordered (controls, containers and contexts) so that situations like this would not happen, and that all this unnecessary methods should be removed (at least for documentation) but nobody listen to me anyway. :D
@Ivan - Thanks for your earlier suggestion and we have decided to make this change after 2.0 release. This is more of a parity issue between iOS and Android platforms.
Glad to hear that. :) Namaskar Neeraj.
As Ivan mentions, ScrollViews being added to labels is not something we will be able to support in Android, because Text controls do not allow this type of embedding. We will address the view container vs widget problem in the upcoming UI Layout Spec
Closing ticket as invalid with reference to the above comments.