Xamarin Forms:如何修复滚动视图中屏幕中心的活动指示器 [英] Xamarin Forms : How to fix Activity Indicator in Centre of Screen in Scrollview
问题描述
我在 AbsoluteLayout
上有一个 ScrollView
..我需要修复 ActivityIndicator 在屏幕中央的位置.我尝试了以下代码.
I have a ScrollView
over AbsoluteLayout
..
I need to Fix the postion of the ActivityIndicator in centre of screen.
I tried following code.
<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
的中心.
and I find the result as its in the centre of the ScrollView
.
我尝试将 ActivityIndicator
放在 ScrollView
的外面,它只是将白屏作为输出.
I tried by placing the ActivityIndicator
out side the ScrollView
it simply gives white screen as output.
如何固定 ActivityIndicator
在屏幕中央的位置?
How do I fix the position of the ActivityIndicator
in centre of screen ?
推荐答案
正如@Vahid 所说,如果你想把 ActivityIndicator
放在 ScrollView
之上,你需要把两者都放在在 AbsoluteLayout 中,像这样:
As @Vahid said, if you want the ActivityIndicator
over the ScrollView
, you need to put both inside an AbsoluteLayout, like this:
<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
上的等待覆盖" - 而不是整个屏幕.
Notice that I added an extra AbsoluteLayout
that works like a 'wait overlay' over the ScrollView
only - not the whole screen.
这篇关于Xamarin Forms:如何修复滚动视图中屏幕中心的活动指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!