禁用Xamarin表格并显示活动指示器

禁用Xamarin表格并显示活动指示器

本文介绍了禁用Xamarin表格并显示活动指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用滚动视图的Xamarin表单。
我试图在顶部显示一个活动指示器,因为中间有一个ListView。
但是,当用户向下滚动时,不会显示加载。
因此,我需要帮助禁用页面并在弹出窗口中显示z-index处的加载。

I have a Xamarin Form which is using Scroll View.I am trying to show a Activity Indicator at the top as I have a ListView in the middle.But when the user scrolls down the loading is not shown.So, I need help in disabling the page and showing loading at some z-index as in a popup.

推荐答案

如果要在屏幕加载时使用叠加层,则可以这样做。

If you want to have an overlay while the screen is loading you can do this.

<Grid>

    <ScrollView>
       <!-- Insert your page content in here -->
    </ScrollView>

    <ContentView IsVisible="false" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
         <ActivityIndicator IsRunning="false" />
    </ContentView>

</Grid>

将ContentView设置为IsVisible = true时,它将覆盖在页面顶部。如果需要提供灰色效果,可以在ContentView上设置背景颜色和不透明度。

When you set your ContentView to IsVisible="true" it will then overlay on top of your page. You can set the background color and opacity on the ContentView if needed to provide a grey out effect.

或者您可以使用类似的方法并

Or you can use a similar method and have

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <ActivityIndicator Grid.Row="0" />

    <ScrollView Grid.Row="1">

    </ScrollView>
</Grid>

这样,您将始终在滚动视图上方具有活动指示器,并允许用户仍然滚动。

In this way you will have the activity indicator above the scroll view at all times and allow the user to still scroll.

这篇关于禁用Xamarin表格并显示活动指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 09:57