Reputation: 1760
Volley's NetworkImageView
can be given a default image to show before the actual loading is done in code via networkImageView.setDefaultImageResId(int)
.
How to do the same from a resource XML file?
Upvotes: 4
Views: 3426
Reputation: 22556
The way I do it is your simply set the android:src=""
to the desired drawable. That will then set the initial image. Once volley has fetched the correct image (which you specify in code during run time) it will replace this one.
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/listview_item_product_list_imageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="left"
android:src="@drawable/loading_image" />
Upvotes: 1
Reputation: 8690
There doesn't seem to be a way.
In the source file, all of the NetworkImageView
's constructors simply call the super constructor (the ImageView
constructor), thus there is no custom handling of the AttributeSet
received in the constructor.
If you'd like, you can edit the constructor in the source file and add a piece of code that searches for an XML attribute that sets the default image. It shouldn't be difficult as the default image functionality already exist.
Upvotes: 3