我正在开发带有聊天屏幕的应用程序。但与普通屏幕一样,它开始从上到下滚动。但应该是从下到上。该应用程序位于 Telerik Nativescript 平台中。
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 代码,请告诉我。
提前致谢。
在你的 ScrollView 上你可以使用滚动到垂直偏移您可以在其中传递要滚动到的偏移量。
例如: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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)