title: Images disappear when scrolling up and down and spaces increase between images using Glide and RecyclerView
body: <p>I have a <code>RecyclerView</code> to display my images and I use Glide to load images from their <code>URLs</code> from my database in Firebase Storage.</p>
  
  <p>The problem is, when I scroll up and down, images reload and sometimes disappear and spaces between each image increase. How can I stop this?</p>
  
  <p>My RecyclerViewAdapter</p>
  
  <pre><code>@Override
  public myViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.image_layout,parent,false);
      myViewHolder myViewHolder = new myViewHolder(row);
      return myViewHolder;
  }
  
  @Override
  public void onBindViewHolder(final myViewHolder holder, int position) {
      final int x = position;
      imageClass = myClassImageList.get(position);
          Glide.with(context)
                  .load(imageClass.getName().trim())
                  .diskCacheStrategy(DiskCacheStrategy.ALL)
                  .fitCenter()
                  .into(holder.imageView);
          holder.imageView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  new MyAsyncTask().execute(myClassImageList.get(x).getName());
  
              }
          });
  }
  </code></pre>
  
  <p>And how I send my List to Adapter</p>
  
  <pre><code>      for(int i=0;i&lt;imageNames.size();i++) {
          StorageReference ref = storageReference.child("filee/" + imageNames.get(i));
          ref.getDownloadUrl().addOnSuccessListener(new OnSuccessListener&lt;Uri&gt;() {
              @Override
              public void onSuccess(Uri uri) {
                  String imageURL = uri.toString();
                  ImageClass imageClass = new ImageClass();
                  imageClass.setName(imageURL);
                  list.add(imageClass);
                  recyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));
  
                  Toast.makeText(MainActivity.this, "Downloaded", Toast.LENGTH_SHORT).show();
  
              }
          }).addOnFailureListener(new OnFailureListener() {
              @Override
              public void onFailure(@NonNull Exception exception) {
                  Toast.makeText(MainActivity.this, "Not Downloaded", Toast.LENGTH_SHORT).show();
              }
          });
  
      }
      adapter = new ImageRecyclerAdapter(MainActivity.this,list);
      recyclerView.setAdapter(adapter);
  </code></pre>
  
  <p><strong>Edit:</strong> I solved the space problem between images by deleting the LinearLayout in the imageLayout.</p>
  
  <p>Now my problem is that images reload when I scroll up and down.</p>