【发布时间】:2017-04-12 21:09:25
【问题描述】:
我正在使用 Nativescript 为从右到左的语言(如波斯语或乌尔都语)创建 android 应用程序。我有水平滚动视图,其中项目使用中继器填充。中继器将通过 webservice 获取项目数据,然后将其放入滚动视图中。
<ScrollView id="pishnehadScroll" orientation="horizontal" propertyChange="pchange">
<Repeater items="{{ products }} ">
<Repeater.itemsLayout>
<StackLayout orientation="horizontal" horizontalAlignment="center">
</StackLayout>
</Repeater.itemsLayout>
<Repeater.itemTemplate>
<StackLayout class="pishnehad-items" horizontalAlignment="center">
<Image src="{{ imagesrc }}" />
<Label text="{{ productprice }}" />
</StackLayout>
</Repeater.itemTemplate>
</Repeater>
</ScrollView>
由于我需要从右到左显示滚动视图项目,我必须获取 scrollView 的 scrollableWidth 属性并使用 scrollToHorizontalOffset 函数。 问题是随着 web 服务结果的到来,可滚动宽度不断变化。 如何获得滚动视图的最终可滚动宽度并设置 scrollToHorizontalOffset 函数以显示滚动视图中的最后一项(最右边的项目)?
【问题讨论】:
-
您可以使用 RadListView(nativescript-telerik-ui 包的一部分)代替 ScrollView。它允许您设置列表视图的水平方向,以及滚动到特定索引 - docs.telerik.com/devtools/nativescript-ui/Controls/NativeScript/…
标签: android nativescript