Problem
ScrollView does not scroll when it contains TableView.
Test case
To see that, run this example:
function createContent() {
var wrapper = Ti.UI.createView({
width: Ti.UI.FILL,
height: Ti.UI.SIZE,
backgroundColor: '#f00',
horizontalWrap: true,
layout: 'horizontal'
});
var label1 = Ti.UI.createLabel({
text: 'Label 1',
width: '50%'
});
var cb1 = Ti.UI.createSwitch({
value: false
});
wrapper.add(label1);
wrapper.add(cb1);
return wrapper;
}
var win = Ti.UI.createWindow({
navBarHidden: true
});
var scrollView = Ti.UI.createScrollView({
height: Ti.UI.FILL,
width: Ti.UI.FILL,
backgroundColor: '#0f0',
layout: 'vertical',
contentHeight: Ti.UI.SIZE,
contentWidth: Ti.UI.FILL
});
win.add(scrollView);
for (var i = 0; i < 10; ++i) {
scrollView.add(createContent());
}
var table = Ti.UI.createTableView({
backgroundColor: '#00f',
height: Ti.UI.SIZE
});
scrollView.add(table);
var rows = [];
for (i = 0; i < 25; ++i) {
rows.push({ title: 'Row ' + i});
}
table.setData(rows);
win.open();
Try to scroll. You'll see that scrolling is not happening.
Expected result
ScrollView should scroll.
Works fine on iOS.
Note that the docs explicitly recommend against the reverse case--putting a scrollview in a tableview--because nesting two scrolling controls like this can make for unfortunate user experience. We should probably recommend against this case as well. It's true that in iOS, if you size the table view height to Ti.UI.SIZE as you're doing here, it works. It also works on Mobile Web, so you could make an argument for fixing this on Android. However, you can also get the same effect by creating a single table view with two sections, and it works on all three platforms.
Issue reproduces with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4
Nested scrolling support on Android was added in Titanium 6.2.2. See [TIMOB-25086].