我有一个 ScrollView
在 AbsoluteLayout
..
我需要修复 ActivityIndicator 在屏幕中央的位置。
我尝试了以下代码。
<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 所说,如果你想要 ActivityIndicator
过ScrollView
,您需要将两者都放在 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/