钛卷轴视图

ika*_*ita 1 scrollview appcelerator appcelerator-titanium

我有一个问题关于scrollviewAppcelerator的钛,我想里面滚动标签scrollview:

scrollpage.xml

    <View id="content" layout="vertical" top="100dp" width="100%">


        <ScrollView contentWidth="Ti.UI.SIZE" contentHeight="Ti.UI.SIZE" top="10dp" id="svc" height="48dp" backgroundColor="#ff0000" >
        </ScrollView>
    </View>

</Window>
Run Code Online (Sandbox Code Playgroud)

scrollpage.js

for ( i = 0; i < 19; i++) {

    var scrollLabel = Ti.UI.createLabel({
        width : Ti.UI.SIZE,
        height : '40dp',
        font : { fontSize : 14 },
        color:'#000',
        text : 'Portfolio'+i,
        id:'label_'+i,
    });

    $.svc.add(scrollLabel);
}
Run Code Online (Sandbox Code Playgroud)

结果 结果

我试过,ScrollableView但我想要很多项目直接在屏幕上显示.

我的目标是实现这个目标:

水平滚动标签

请解释我做错了什么!谢谢!

Tho*_*tre 7

那是因为默认情况下,ScrollView的布局是复合的.因此,如果您想要不同的布局,请添加layout="horizontal"ScrollableView以放置您的子元素:

<ScrollView contentWidth="Ti.UI.SIZE" contentHeight="Ti.UI.SIZE" top="10dp" id="svc" height="48dp" backgroundColor="#ff0000" layout="horizontal"></ScrollView>
Run Code Online (Sandbox Code Playgroud)

有关布局的更多信息:http://docs.appcelerator.com/platform/latest/#!/guide/Layouts,_Positioning,_and_the_View_Hierarchy-section-29004895_Layouts,Positioning,andtheViewHierarchy-Layoutmodes