自动滚动到底部 [英] Auto scroll to Bottom

查看:160
本文介绍了自动滚动到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用聊天屏幕进行申请。但正如普通屏幕一样,它开始从上到下滚动。但它应该是从底部到顶部。该应用程序位于Telerik Nativescript平台中。

I am working on application with chat screen. But as normal screen it starts scrolling from top to bottom. But its should be from bottom to top. The application is in Telerik Nativescript platform.

View.xml

<ScrollView row="0" col="0">  
    <StackLayout class="history-content-area">
        <Repeater items="{{messageHistory}}">
            <Repeater.itemTemplate>
                <StackLayout>
                    <!-- ITEMS GO HERE -->
                </StackLayout>
            </Repeater.itemTemplate>
        </Repeater>
    </StackLayout>
</ScrollView>

我在上面的代码中需要帮助如何在页面加载时自动滚动到底部?如果您需要javascript代码,请告诉我。

I need help in above code how can i scroll to bottom automatically on page load ? Let me know if you need javascript code.

提前致谢。

推荐答案

在ScrollView上,您可以使用 scrollToVerticalOffset ,您可以在其中传递偏移量以滚动到。

On your ScrollView you can use scrollToVerticalOffset where you can pass the offset to scroll to.

例如:
view.xml

For example: view.xml

<ScrollView row="0" col="0" id="myScroller">  
    <StackLayout class="history-content-area">
        <Repeater items="{{messageHistory}}">
            <Repeater.itemTemplate>
                <StackLayout>
                    <!-- ITEMS GO HERE -->
                </StackLayout>
            </Repeater.itemTemplate>
        </Repeater>
    </StackLayout>
</ScrollView>

view.js

mScroller = page.getViewById("myScroller");

var offset = mScroller.scrollableHeight; // get the current scroll height
mScroller.scrollToVerticalOffset(offset, false); // scroll to the bottom

这篇关于自动滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆