
Android Application Development Cookbook
By :

Our last recipe on Volley will not be a request per se, but a replacement for the ImageView
. Requesting an image to populate an ImageView
is such a common task; Volley combines the functionality to a new view called NetworkImageView
. This recipe will demonstrate how to use a NetworkImageView
.
Create a new project in Android Studio and call it NetworkImageView
. Use the default Phone & Tablet option and select Empty Activity when prompted for Activity Type.
This recipe will be using the setup described in the Getting started with Volley for Internet requests recipe. Follow Steps 1-5 to add Volley to your new project.
With Volley added to your project as described previously, follow these steps:
activity_main.xml
and replace the existing TextView
with the following XML:<com.android.volley.toolbox.NetworkImageView android:id="@+id/networkImageView" android:layout_width="wrap_content...
Change the font size
Change margin width
Change background colour