xamarin.forms中的Loader图像?

时间:2014-12-06 11:46:22

标签: image xamarin xamarin.forms

如何显示加载程序图像。如果服务正在命中,我想在Xamarin.Forms中显示背景中的加载器图像。

4 个答案:

答案 0 :(得分:2)

Xamarin.Forms有ActivityIndicatorhttp://iosapi.xamarin.com/index.aspx?link=T%3AXamarin.Forms.ActivityIndicator 您可能会找到有关如何使用它的各种代码示例。

如果核心问题是如何在显示任何“加载”指示符时在后台加载某些内容,您可以查看以下示例:http://xforms-kickstarter.com/#asynchronous-web-requests

答案 1 :(得分:0)

你的问题不是很清楚,

我猜你只是想要通过加载动画通知用户,而在后台运行的任务需要一些时间?

检查http://developer.xamarin.com/recipes/ios/standard_controls/popovers/display_a_loading_message/ 以快速简便的方式实现它。这里的代码非常易于编辑,因此您可以根据自己的需要进行调整。

对于跨平台解决方案(Xamarin.Forms),您可能需要查看:

Xamarin Forms show blocking loading message

答案 2 :(得分:0)

为了实现Loader或ActivityIndi​​cator,Xamarin为iOS和android提供了相当不错的组件。即iOS版btprogresshud和Android版Andhud版。这些组件可以通过Xamarin.Forms使用。

答案 3 :(得分:0)

使用Xamarin.Forms的ActivityIndi​​cator。 Click here了解详情。

这是我使用它的方式,您只需要在视图模型中创建一个新属性并将其称为IsLoading,如果将其设置为true,则可以看到Activity Indicator,这就是您所需要的;

// IsLoading property in the viewmodel
  public bool IsLoading
  {
      get
      {
          return isLoading;
      }
      set
      {
          isLoading = value;
          OnPropertyChanged();
      }
  }


//code sample in xaml
  <Grid Grid.Row="1"
  IsVisible="{Binding IsLoading}"
  BackgroundColor="Black"
  Opacity="0.25">
  <Grid.RowDefinitions>
    <RowDefinition Height="1*"/>
    <RowDefinition Height="1*"/>
  </Grid.RowDefinitions>

  <ActivityIndicator  Grid.Row="0"
                      IsVisible="{Binding IsLoading}"
                      IsRunning="{Binding IsLoading}"
                      VerticalOptions="End"
                      HorizontalOptions="Center"/>
  <Label Grid.Row="1"
         Text="Please wait..."
         TextColor="White"
         VerticalOptions="Start"
         HorizontalOptions="Center"/>

</Grid>