【问题标题】:Titanium scrollview钛滚动视图
【发布时间】:2016-03-25 12:24:48
【问题描述】:

我对 appcelerator Titanscrollview 有疑问,我想在 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>

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);
}

结果

我尝试了ScrollableView,但我希望很多项目直接显示在屏幕上。

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

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

【问题讨论】:

  • 你想要的结果是什么?如果我不知道你想要达到什么目标,我帮不了你。
  • 我想要水平滚动标签

标签: scrollview appcelerator appcelerator-titanium


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多