【问题标题】:Xamarin Faster then listviewXamarin 比 listview 更快
【发布时间】:2019-09-14 16:48:34
【问题描述】:

我正在构建一个小说漫画应用程序。

当我接触到小说时,大约有 2000 章,我需要一次渲染它们。

我正在使用列表视图来呈现它们,但它太慢了。

我想知道是否有更快的解决方案,如渲染器或我可以构建的东西,它会运行得更快。

这是我当前的 XAML

 <ListView ItemsSource="{Binding Chapters}"
                      x:Name="grdChapters"
                      ItemSelected="GrdChapters_ItemSelected">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Padding="5" HeightRequest="30">
                                <StackLayout Orientation="Horizontal">
                                    <Label TextColor="Black" Text="{Binding Name}" VerticalOptions="Center" HorizontalOptions="StartAndExpand" Style="{StaticResource header}" FontAttributes="None" />
                                    <Image Source="right.png" HorizontalOptions="End" IsVisible="{Binding Completed}" WidthRequest="16" HeightRequest="16" Aspect="AspectFit" />
                                </StackLayout>
                                <BoxView  Style="{StaticResource lightLine}" />
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

【问题讨论】:

  • 看看新的 CollectionView
  • 更快吗?现在将对其进行测试thx
  • 信不信由你:)
  • 您是否考虑过使用 FFImageLoading 处理图像?我想那是你真正的瓶颈
  • 我没有使用动态 imgae,它只是一个资源图标。所以不需要缓存。这里的问题是总行数

标签: c# android xaml xamarin.forms


【解决方案1】:

RecycleElementAndDataTemplate 应该可以提高您的性能,因为即使您没有使用任何动态图像,列表中所有项目的数据模板都是相同的,并且会得到优化。

如果这没有帮助,我建议使用 Xamarin.Android 的 glidex 库,它使滚动更加顺畅。

【讨论】:

  • RecycleElementAndDataTemplate 冻结我的列表视图。不能事件点击项目:)
  • 奇怪,也许尝试使用 CollectionView 代替?我开始没有选择了哈哈
  • 我得到的唯一解决方案是在滚动时加载更多内容,因此我构建了自己的列表视图。但如果可能的话,我想把它们全部呈现出来。在 java 上非常快,但不是 xamarin
猜你喜欢
  • 1970-01-01
  • 2019-04-23
  • 1970-01-01
  • 1970-01-01
  • 2016-10-03
  • 1970-01-01
  • 1970-01-01
  • 2018-10-16
  • 1970-01-01
相关资源
最近更新 更多