简体   繁体   English

如何在Titanium中插入垂直滚动条

[英]How can I insert vertical scrollbar in Titanium

I'm building an application with Titanium 我正在用Titanium构建应用程序

Now I want to set a scrollview in one Window because the content of this windows is to big of the device. 现在,我想在一个窗口中设置一个滚动视图,因为该窗口的内容对于设备来说很大。 So I want insert a ScrollView and show the vertical scrollbar. 所以我想插入一个ScrollView并显示垂直滚动条。

So I'm building this code: 因此,我正在构建此代码:

<Alloy>
    <Window id="indexWindow" orientation="Titanium.UI.UPSIDE_PORTRAIT"  fullscreen="false">
         <ScrollView id="scrollView" showVerticalScrollIndicator="true"
            showPagingControl= "true" showHorizontalScrollIndicator="true" height="80%" width="80%">

        <View class="container" layout="vertical">
            <!-- title -->
            <Label id="titleDatiAnagrafici" class="labelTitle" ></Label>

            <!-- personal data -->
            <TableView id="form_table" height="Titanium.UI.SIZE">

                <TableViewRow id="name_row" class="row_item" layout="horizontal">
                    <Label id="name_label" class="label" />
                    <Label text="Mario" class="labelData"/>

                    <Label id="surname_label" class="label" left="20px"/>
                    <Label text="Rossi" class="labelData"/>
                </TableViewRow>

                <TableViewRow id="name_row" class="row_item" layout="horizontal">
                    <Label id="address_label" class="label" />
                    <Label text="via Cereate 8, Milano" class="labelData"/>

                </TableViewRow>

                <TableViewRow id="name_row" class="row_item" layout="horizontal">
                    <Label id="phone_label" class="label"/>
                    <Label text="333111222" class="labelData"/>
                </TableViewRow>

            </TableView>



        </View>
        </ScrollView>
    </Window>
</Alloy>

But I can't see the vertical scrollbar. 但是我看不到垂直滚动条。

You must use the height property of the View. 您必须使用视图的height属性。

 <Window id="indexWindow" orientation="Titanium.UI.UPSIDE_PORTRAIT"  fullscreen="false">
     <ScrollView id="scrollView" showVerticalScrollIndicator="true"
        showPagingControl= "true" showHorizontalScrollIndicator="true" height="80%" width="80%">

    <View class="container" layout="vertical" height="2000">
        <!-- title -->
        <Label id="titleDatiAnagrafici" class="labelTitle" ></Label>

        <!-- personal data -->
        <TableView id="form_table" height="Titanium.UI.SIZE">

            <TableViewRow id="name_row" class="row_item" layout="horizontal">
                <Label id="name_label" class="label" />
                <Label text="Mario" class="labelData"/>

                <Label id="surname_label" class="label" left="20px"/>
                <Label text="Rossi" class="labelData"/>
            </TableViewRow>

            <TableViewRow id="name_row" class="row_item" layout="horizontal">
                <Label id="address_label" class="label" />
                <Label text="via Cereate 8, Milano" class="labelData"/>

            </TableViewRow>

            <TableViewRow id="name_row" class="row_item" layout="horizontal">
                <Label id="phone_label" class="label"/>
                <Label text="333111222" class="labelData"/>
            </TableViewRow>

        </TableView>



    </View>
    </ScrollView>
</Window>

By default the view takes the size of its parent so the scrollview will never appear. 默认情况下,视图采用其父视图的大小,因此滚动视图将永远不会出现。

In according with documentation, you can add the following attribute in your ScrollView tag: 根据文档,您可以在ScrollView标记中添加以下属性:

showVerticalScrollIndicator="true"

You can add in the same way also an horizontal bar if you want: 如果需要,也可以用相同的方法添加水平条:

showHorizontalScrollIndicator: true

Look at documentation here 这里查看文档

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM