title: Item animation of RecyclerView in android
body: <p>I had a problem when i use animation in RecyclerView, i want to start a TranslateAnimation on a RelativeLayout of all items and setFillAfter(true) to keep the animation when it end, everything looks like good when animation start, but when i scroll the RecyclerView something appear like below:</p>
  
  <p>[<img src="https://i.stack.imgur.com/t6Kng.gif" alt="1]"></p>
  
  <p>some item's animation lost:</p>
  
  <p>[<img src="https://i.stack.imgur.com/CWHl5.png" alt="2]"></p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class MainActivity extends Activity {
  private static final List&lt;Model&gt; DATA = Model.getModels();
  private List&lt;RelativeLayout&gt; layouts = new ArrayList&lt;&gt;();
  
  @InjectView(R.id.recycler_view)
  RecyclerView recyclerView;
  @InjectView(R.id.main_edit_btn)
  Button btnEdit;
  
  private MainAdapter adapter;
  
  private boolean isEdit;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.ac_main);
      ButterKnife.inject(this);
      recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
      adapter = new MainAdapter();
      recyclerView.setAdapter(adapter);
  }
  
  @OnClick(R.id.main_all_btn)
  public void selectAll() {
  
  }
  
  @OnClick(R.id.main_del_btn)
  public void delete() {
  
  }
  
  @OnClick(R.id.main_edit_btn)
  public void edit() {
      if (isEdit) {
          btnEdit.setText("Edit");
          isEdit = false;
          for (Model model : DATA) {
              model.isEdit = false;
          }
      } else {
          btnEdit.setText("Cancel");
          isEdit = true;
          for (Model model : DATA) {
              model.isEdit = true;
          }
      }
      adapter.notifyDataSetChanged();
  }
  
  class MainAdapter extends RecyclerView.Adapter&lt;MainAdapter.MainHolder&gt; {
      @Override
      public MainHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          return new MainHolder(LayoutInflater.from(MainActivity.this)
                  .inflate(R.layout.ac_main_item, parent, false));
      }
  
      @Override
      public void onBindViewHolder(MainHolder holder, int position) {
          holder.tvTitle.setText(DATA.get(position).title);
          holder.tvDate.setText(DATA.get(position).date);
          if (DATA.get(position).isEdit) {
              holder.startAnim();
          }
      }
  
      @Override
      public int getItemCount() {
          return DATA.size();
      }
  
      class MainHolder extends RecyclerView.ViewHolder {
          @InjectView(R.id.main_item_title_tv)
          TextView tvTitle;
          @InjectView(R.id.main_item_date_tv)
          TextView tvDate;
          @InjectView(R.id.main_item_content_rl)
          RelativeLayout rlContent;
  
          public MainHolder(View itemView) {
              super(itemView);
              ButterKnife.inject(this, itemView);
          }
  
          public void startAnim() {
              Animation anim = new TranslateAnimation(0, 100, 0, 0);
              anim.setDuration(500);
              anim.setFillEnabled(true);
              anim.setFillAfter(true);
              rlContent.startAnimation(anim);
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Is anyone can help me how to solve this problem?thx.</p>