Volley Image Caching

后端 未结 7 2065
臣服心动
臣服心动 2020-12-09 18:18

I am trying to understand Volley\'s image caching. I have a fragment with gridview inside it, which will load around 12-30 images. There images are retrieved from server and

7条回答
  •  青春惊慌失措
    2020-12-09 19:15

    Consider using Glide which android recommends for loading images in your app. Compared to volley, Glide provides automatic image caching.

    To add Glide in your app:

    Step 1 ) Update build.gradle file

    dependencies {
        compile 'com.github.bumptech.glide:glide:3.6.1'
        compile 'com.android.support:support-v4:19.1.0'
      }
    

    Step 2) Add INTERNET permission in manifest file

    
    

    Step 3) Add ImageView in you layout

    
    
    

    Step 4) Glide Usage in Activity

        //Initialize ImageView
        ImageView imageView = (ImageView) findViewById(R.id.imageView);
    
        //Loading image from below url into imageView
       Glide.with(this)
            .load("IMAGE URL HERE")
            .placeholder(R.drawable.placeholder)
            .error(R.drawable.imagenotfound)
            .override(200, 200);
            .centerCrop();
            .into(imageView);
    

    Read more on Android Glide Library

提交回复
热议问题