0

I'm developing a Xamaring.Forms cross-platform app, and want to show Loading gif when user click a button to connect to the server. Everythink is working as expected except the gif image is not shown, even when I try with a different format of images I also don't see any images.

  • I have Installed all the required packages of ffimageloading and the gif image locate in project root ,drawable folder of android project and Resources folder of IOS project.
  • I gave the property of Embedded Resource to the image in Android project.
  • I'm using Android emulator to test the Android project.
  • I'm using Xamarin Live Player to test the IOS project

Hier is my code:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"  
         xmlns:ffSvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"  
         xmlns:ffTransformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations"  
         x:Class="MyApp.Login"
         Title="Login"
         NavigationPage.HasNavigationBar="False">
<ContentPage.Padding>
    <OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0"/>
</ContentPage.Padding>
<ContentPage.Content>
    <AbsoluteLayout BackgroundColor="White">

        <StackLayout VerticalOptions="StartAndExpand" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">
            <Image Source="Logo.png" Aspect="AspectFit"/>
            <StackLayout Padding="30, 10, 30, 0">
                <Label x:Name="errormessage" TextColor="Red"/>
                <Entry x:Name="EmailEntry" Placeholder="Email" Keyboard="Email" Margin="0, 10"/>
                <Entry x:Name="PasswordEntry" IsPassword="true" Placeholder="Password" />
                <Entry x:Name="CompanyEntry" Placeholder="Company" />
                <Button x:Name="LoginBtn" Pressed="Pressed_Handler" Text="Login" Clicked="Login_Handler" BackgroundColor="Black" TextColor="White" FontAttributes="Bold" Margin="90, 30" />
            </StackLayout>
        </StackLayout>

        <StackLayout x:Name="LoadingView" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="Black" Opacity="0.3">
        </StackLayout>

        <StackLayout x:Name="LoadingView2" AbsoluteLayout.LayoutBounds="0.5,0.5,200,200" AbsoluteLayout.LayoutFlags="PositionProportional" BackgroundColor="Black">
            <Label Text="Loading..." TextColor="White" FontAttributes="Bold" FontSize="30" VerticalOptions="Center"/>

            <!-- ------------- here is the gif image ----------------- -->
            <ff:CachedImage x:Name="Gif" Source="resource://MyApp.LoadingGif.gif" />
        </StackLayout>

    </AbsoluteLayout>
</ContentPage.Content>

Saad Hasan
  • 458
  • 5
  • 17

1 Answers1

0

This is not how resource:// should be used. It is used to share the same file inside common dll. You're using it as a platform specific file, change:

Source="resource://MyApp.LoadingGif.gif" to Source="LoadingGif.gif"

Daniel Luberda
  • 7,374
  • 1
  • 32
  • 40