I'm trying to add some imageViews and a tableView into scrollView in Titanium. I want the scrollView to be scrollable but not the tableView inside, so I set tableView.scrollable to false. However, even if the height of the scrollView exceeds the height of the screen, it is not scrollable. Since it's not encouraged to put a tableView inside a scrollView, I'm wondering if there is a better way to create a table with fixed length inside a scrollView in Titanium?
The following is my code:
var view = Ti.UI.createScrollView({
contentWidth:'auto',
contentHeight:'auto',
top:0,
showVerticalScrollIndicator:true,
showHorizontalScrollIndicator:true,
});
var imageview1 = Ti.UI.createImageView({
image: "../images/headers/gscs_logo.png",
height: 80,
left: 10,
right: 10,
top: 10,
});
var imageview2 = Ti.UI.createImageView({
image: "../images/headers/wellness_logo.png",
height: 80,
left: 10,
right: 10,
top: 90,
});
view.add(imageview1);
view.add(imageview2);
var tableview = Ti.UI.createTableView({
data: [{title:'a'}, {title:'b'}, {title:'c'}, {title:'d'}, {title:'e'}, {title:'f'}, {title:'g'}],
top: 180,
scrollable: false,
});
view.add(tableview);
Ti.UI.currentWindow.add(view);
This is the window I got (StackOverflow does not allow new users to post images, sorry).
This is the window I want. The table has fixed number of rows and its parent view can be scrolled.
I have also tried to set currentWindow.layout to "vertical", but that failed since neither the scrollView nor the tableView would show up.
Thank you for your patience and help!
UITableView
to aUIScrollView
, as the touch events will not be sent properly. – msgambel