![](/img/trans.png)
[英]Titanium: ImageView for Android that is scrollable horizontal AND vertical
[英]Titanium android horizontal scrollable tableview
我們可以使鈦金屬的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});
請建議我應該采取什么解決方案。謝謝。
我認為您不能使tableview
水平滾動。 但是您可以將scrollView
用作tableView
。
根據文檔:
添加到滾動視圖的視圖將根據內容的可滾動區域的大小進行滾動。 如果可滾動區域適合其滾動視圖的大小,則該視圖將不會滾動。
在Android上,您只能在一個方向(垂直或水平)上滾動滾動視圖,而不能同時在兩個方向上滾動。 您可以使用scrollType屬性來顯式設置滾動方向 。
從文檔:
如果未定義scrollType屬性,則滾動視圖將嘗試根據已設置的其他一些屬性推導滾動方向。 具體地說,如果contentWidth和width都設置並且彼此相等,或者如果都設置並且showVerticalScrollIndicator設置為true,則滾動方向設置為“ vertical”。 如果contentHeight和height都設置並且相等,或者都設置了並且showHorizontalScrollIndicator設置為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();
我已經嘗試過了,它正在工作。 希望對您有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.