C# 活动指示器未以中间文件显示-WinPhone81
我在XamarinForms项目中遇到了ActivityIndicator的一种奇怪行为。指示器在WiPoNe818中完美地加载,但不是第一次在布局中间,但是它从第二次到无穷大完美地工作。下面是我使用的代码: 在XAML中:C# 活动指示器未以中间文件显示-WinPhone81,c#,xamarin.forms,C#,Xamarin.forms,我在XamarinForms项目中遇到了ActivityIndicator的一种奇怪行为。指示器在WiPoNe818中完美地加载,但不是第一次在布局中间,但是它从第二次到无穷大完美地工作。下面是我使用的代码: 在XAML中: <StackLayout x:Name="blueBar" Padding ="0,0,0,0" Orientation ="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExp
<StackLayout x:Name="blueBar" Padding ="0,0,0,0" Orientation ="Vertical"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
</StackLayout>
有人知道为什么会这样吗
任何建议/指导/帮助都将不胜感激
提前谢谢
Note: The ActivityIndicator works well and fine in Droid & iOS projects.
输出:正如我所经历的
1.第一次执行页面:
2.第二次执行同一页面:
输出:根据-Chandresh Khambhayata
似乎您需要首先将StackLayout放入AbsoluteLayout中,以便将ActivityIndicator调整到中间位置 这应该对你有帮助 我还没有尝试过这个,但是看起来你需要做很多事情来实现它
希望有帮助 如果要在屏幕中央显示ActivityIndicator,则必须应用HorizontalOptions=center和VerticalOptions=center 我正在使用下面的XML代码,它非常适合我
<StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
<ActivityIndicator Color="White" HorizontalOptions="Center" VerticalOptions="Center" />
<Label Grid.Row="1" x:Name="LabelLoading" HorizontalOptions="Center" TextColor="White" Text="Loading..." FontFamily="Droid Sans Mono" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />
</StackLayout>
谢谢你。谢谢你帮了我,伙计们 我终于为我的问题找到了答案 这是我在所有三个平台上的工作代码 XAML:
<StackLayout x:Name="blueBar" Padding="0,0,0,0" Orientation="Vertical" VerticalOptions="FillAndExpand" >
<ActivityIndicator x:Name="loading" IsRunning="true"></ActivityIndicator>
</StackLayout>
实际问题是,。该指示器之前未通过InitializeComponent分配。因此,当我第一次单击任何按钮时,。指示器显示在布局的左侧
但是,现在的指示器是由初始化变量初始化的,因此指示器在第一次点击的中间显示……/P>
Note : This problem only occured on windowsphone only not on ios and android projects.
Now the updated code works well and good on all the three platforms.
这应该行得通。但我不是很确定,当这是编程完成的。谢谢你们宝贵的时间伙计们。。。但是我运气不好。。。在我的问题中,我将把上述代码的输出添加为图像。请看一看…@Senthamizh你想使用屏幕上的指示器吗?不,绝对不想@ChandreshKhambhayata我只想在布局中添加一段时间,然后在执行一些功能后删除它。。。我用图片更新了我的问题。你能解释一下你的问题吗?我想我们的意见不一致。谢谢你的快速回复。。但它在Droid和iOS上运行良好。。。顺便说一句,你共享的链接是死链接。。。我的意思是你共享的链接不起作用,很可能是断开了,这是因为https,有人已经编辑了它。再次查看:这个链接很有帮助,但是我不想在屏幕上覆盖那个指示器。。。只需将指示器添加到布局并在一段时间后将其删除即可。。就这么简单。。。
<StackLayout x:Name="blueBar" Padding="0,0,0,0" Orientation="Vertical" VerticalOptions="FillAndExpand" >
<ActivityIndicator x:Name="loading" IsRunning="true"></ActivityIndicator>
</StackLayout>
somebtn.Clicked += async(sender,e) => {
loading.IsVisible = true;
//some await functions like api call or something
loading.IsVisible = false;
}
Note : This problem only occured on windowsphone only not on ios and android projects.
Now the updated code works well and good on all the three platforms.