0

我们可以制作一个钛的android android tableview水平滚动。 我想这Titanium android水平滚动tableview

var scrollAlbums = Ti.UI.createScrollView({ 
bottom : 10, 
backgroundColor:'green', 
contentHeight : Ti.UI.SIZE, // add this 
contentWidth : Ti.UI.SIZE, // change this 
height : 95, 
layout : 'horizontal', 
showHorizontalScrollIndicator : false, 
showVerticalScrollIndicator : true, // should be a visual indication if can scroll 
scrollType : 'horizontal', 
horizontalWrap : false, 
width : Ti.UI.FILL // assuming you need it full width - if not specify a width 
}); 

// Create a TableView. 
var aTableView = Ti.UI.createTableView({width:1000,backgroundColor:'red',height:200}); 

请建议我应该是什么that.Thanks可能的解决方案。

+0

您是否试过Titanium ScrollableView。那个会水平滚动。 – Anand

+0

谢谢阿南德。是的,我尝试过,但我真正想要的是视图应该只有一个像我做一个tableview,并定义它的大宽度,并添加在一些水平滚动。有意义的吗? – Ali

回答

0

我认为你不能让一个tableview水平滚动。但是您可以使用scrollView作为tableView

根据文档:添加到该滚动视图

视图将基于对 的内容可滚动区域的大小来滚动。如果可滚动区域适合其滚动视图的大小,则该视图不会滚动。

在Android上,您只能在一个方向上滚动滚动视图,不管是垂直还是水平,而不是同时滚动。您可以使用scrollType属性明确设置滚动方向

从文档:

如果没有定义的scrollType属性,滚动视图尝试 推断基于一些 已经设置的其他属性的滚动方向。具体来说,如果contentWidth和width都设置为 并且彼此相等,或者它们都设置了,并且 showVerticalScrollIndicator设置为true,则滚动方向 设置为“垂直”。如果contentHeight和height都设置为 ,或者它们都设置并且showHorizo​​ntalScrollIndicator为 设置为true,则滚动方向设置为“水平”。如果设置了 scrollType,它将覆盖推导的设置。

请看看下面的例子

var win = Ti.UI.createWindow({ 
    backgroundColor: 'white', 
    exitOnClose: true, 
    fullscreen: false, 
    title: 'Horizontal ScrollView Demo' 
}); 

var scrollView = Ti.UI.createScrollView({ 
    contentWidth : 'auto', 
    contentHeight : 'auto', 
    scrollType : 'horizontal', 
    showHorizontalScrollIndicator: true 
}); 

var containerView = Ti.UI.createView({ 
    width  : 2000, 
    layout  : 'horizontal', 
    height  : 300, 
    backgroundColor : '#000' 
}); 

var columns = []; 
for(var index=0;index<15;index++){ 
    columns[index] = Ti.UI.createView({ 
     width : 200, 
     height : 200, 
     backgroundColor : '#123456', 
     left : 20 
    }); 
    containerView.add(columns[index]); 
} 
scrollView.add(containerView); 
win.add(scrollView); 
win.open(); 

我曾经尝试这样做,它的工作。希望它对你有所帮助。