Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Show loading symbol in Network ImageView

I am using NetworkImageView from Volley library to load images.

But while the image takes time load from a URL I want to show a spinning/moving loading symbol in the image container.

I tried using the setDefaultImageResId() function to set a loader.gif image. But I think gif format is not supported in Android natively.

Please advice. Thanks.

like image 691
Dragon Avatar asked Dec 11 '22 06:12

Dragon


1 Answers

You Just need to put the NetworkImageView and the ProgressBar inside a FrameLayout or a RelativeLayout,something like this

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >

     <ProgressBar
            style="?android:attr/progressBarStyle"
            android:layout_width="..."
            android:layout_height="..." />

    <com.android.volley.toolbox.NetworkImageView
        android:layout_width="..."
        android:layout_height="..."
         />

</FrameLayout>

be aware that the ORDER COUNTS, make sure you put the NetworkImageView after the ProgressBar so that the NetworkImageView stays on top of the ProgressBar after loading the image.

Hope it helps!

like image 110
manuelvsc Avatar answered Jan 18 '23 13:01

manuelvsc