title: RecyclerView: itemView.setVisibility(View.GONE) hides all items below the itemView
body: <p>I have implemented a favorites list in Android and have created a <strong>recyclerView</strong> for it. In the <strong>recyclerView</strong> each item being displayed have a button named <code>btnRemove</code> to remove the item from the favorite list. </p>
  
  <p>After clicking <code>btnRemove</code> of the corresponding item:</p>
  
  <ol>
  <li>If the item is at bottom, only that item hides from the list.</li>
  </ol>
  
  <p><strong>BUT</strong></p>
  
  <ol start="2">
  <li>If the item lies on the top or in the center, it hides along with all items below it. <strong><em>This is my issue</em></strong></li>
  </ol>
  
  <p>Following is my code for setting RecyclerView inside my activity class:</p>
  
  <pre><code>    RecyclerView rv_fav=v.findViewById(R.id.listFavourites);
      rv_fav.setLayoutManager(new LinearLayoutManager(this.getContext()));
      FavListAdapter adapter=new FavListAdapter(this.getContext());
  </code></pre>
  
  <p>Inside <code>FavListAdapter</code> class where I am hiding the views by following code:</p>
  
  <pre><code>public void onBindViewHolder(final MyViewHolder holder, final int position) {
  
  ...
  ...
  
       holder.btnRemove.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                              fav_list.remove(position);
  
                              holder.itemView.setVisibility(View.GONE);
  
                              //holder.itemView.setLayoutParams(new RecyclerView.LayoutParams(0, 0));   //I also tried this but got the same result
  
  
  
  
                  }
              });
      }
  </code></pre>
  
  <p>I also tried the following code but the result was same:</p>
  
  <pre><code>holder.itemView.setLayoutParams(new RecyclerView.LayoutParams(0, 0)); 
  </code></pre>
  
  <p>Thanks in advance for your help!</p>