xaml - Xamarin 表单 : How to fix Activity Indicator in Centre of Screen in Scrollview

标签 xaml xamarin xamarin.forms uiscrollview

我有一个 ScrollViewAbsoluteLayout ..
我需要修复 ActivityIndi​​cator 在屏幕中央的位置。
我尝试了以下代码。

<ScrollView>
    <AbsoluteLayout VerticalOptions="FillAndExpand"
                    HorizontalOptions="FillAndExpand">
        <StackLayout BackgroundColor="White"
                     Padding="50,20,50,20"
                     Spacing="5"
                     AbsoluteLayout.LayoutBounds="0,0,1,1"
                     AbsoluteLayout.LayoutFlags="All"> 
            // have set of elements..
        </StackLayout>
        <ActivityIndicator IsVisible="{Binding IsBusy}"
                           IsRunning="{Binding IsBusy}"
                           Color="Black"
                           AbsoluteLayout.LayoutBounds="0.5,0.5,0.1,0.1"
                           AbsoluteLayout.LayoutFlags="All"/>
    </AbsoluteLayout>
</ScrollView>

我发现结果在 ScrollView 的中心.

我尝试放置 ActivityIndicator外面ScrollView它只是将白屏作为输出。

如何固定 ActivityIndicator 的位置在屏幕中央?

最佳答案

正如@Vahid 所说,如果你想要 ActivityIndicatorScrollView ,您需要将两者都放在 AbsoluteLayout 中,如下所示:

<AbsoluteLayout VerticalOptions="FillAndExpand"
                HorizontalOptions="FillAndExpand">
    <ScrollView AbsoluteLayout.LayoutBounds="0,0,1,1"
                AbsoluteLayout.LayoutFlags="All"
                VerticalOptions="FillAndExpand"
                HorizontalOptions="FillAndExpand">
        <StackLayout BackgroundColor="White"
                     Padding="50,20,50,20"
                     Spacing="5">
            // Your stuff goes here
        </StackLayout>
    </ScrollView>
    <AbsoluteLayout BackgroundColor="#22000000"
                    AbsoluteLayout.LayoutBounds="0.5,0.5,1,1"
                    AbsoluteLayout.LayoutFlags="All"
                    IsVisible="{Binding IsBusy}">
        <ActivityIndicator Color="Black"
                           AbsoluteLayout.LayoutBounds="0.5,0.5,0.1,0.1"
                           AbsoluteLayout.LayoutFlags="All"
                           IsVisible="True"
                           IsRunning="True"/>
    </AbsoluteLayout>
</AbsoluteLayout>

请注意,我添加了一个额外的 AbsoluteLayout这就像 ScrollView 上的“等待覆盖”只有 - 不是整个屏幕。

关于xaml - Xamarin 表单 : How to fix Activity Indicator in Centre of Screen in Scrollview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48295792/

相关文章:

c# - Validation.HasError 未针对针对 IDataErrorInfo 验证的 DataGrid 触发

c# - 使用 C# 和 XAML 在 Windows Phone 8.1 应用程序中更新或刷新 Listview

xaml - Telerik RadMaskedNumericInput 掩码

c# - Xamarin 自定义 TableView header

c# - 如何在一个按钮中设置两种不同大小的文本,android api > 24

c# - Xamarin C# - 代码更改不会改变程序的工作

ios - 无效 bundle 。 bundle xxx 不支持最低操作系统版本 (2020)

xamarin.forms - 使用 PKCE OAuth 和 .NET API 从 Xamarin Forms 访问 Dropbox - 解决方案

c# - 如何根据反序列化 json 字符串的响应在两个类之间切换?

c# - 在屏幕中缩小时,部分 View 神奇地消失了(Android 上的 Xamarin Forms)