Montoolivo
Montoolivo

Reputation: 147

How to show loading spinner in activity while this activity is loading(Xamarin.Android)?

I have the following MainActivity

enter image description here

When I click its GO TO SECOND ACTIVITY button I go to SecondActivity but as in SecondActivity I have a very big zoomable image, the application stays on MainActivity for about 2, 3 seconds and then SecondActivity opens. Тo prevent the user from thinking that the GO TO SECOND ACTIVITY button doesn't work, I want to open SecondActivity as soon as the user presses GO TO SECOND ACTIVITY button and show а loading spinner in place of the image while the image is loading.

Here is my SecondActivity.axml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageLoadingDemo.ScaleImageView
        android:src="@drawable/ic_map"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

Upvotes: 0

Views: 228

Answers (1)

hadilionson
hadilionson

Reputation: 96

you first add a nuget pack like "urlimageviewhelper", that works fine for me then use this code instead common way

    Koush.UrlImageViewHelper.SetUrlDrawable(ImageViewSample, "ImageUrl", Resource.Drawable.Preloaing, IntNumber);

in the above code use 600000 for 10 minus cache Imgae

Resource.Drawable.Preloaing: it's preload image

So the activity loads fast and image show after loading

Upvotes: 1

Related Questions