How to animate recyclerview on scroll like Google plus/Google newsstand?

前端 未结 4 1103
囚心锁ツ
囚心锁ツ 2020-12-04 10:12

How do I animate the RecyclerView when the items appear for first time and also when the user scrolls, just like the way it works for the google plus app or the

4条回答
  •  醉梦人生
    2020-12-04 11:00

    https://github.com/wasabeef/recyclerview-animators

    In my code is something like this:

    import jp.wasabeef.recyclerview.animators.adapters.AlphaInAnimationAdapter;
    
    ....
    
    public function populate() {
       // Get your recicleview
       rv = (RecyclerView)findViewById(R.id.rv);
       rv.setHasFixedSize(true);
    
       // Populate your cursor with your own method...
       Cursor myRecycleItems= null;
       myRecycleItems= mDbHelper.getItems();
    
       //create your 
       itemsAdapter= new ItemsAdapter(myRecycleItems, getApplicationContext());
    
    
       //Finnaly apply your adapter to RV with AlphaInAnimationAdapter:
       rv.setAdapter(new AlphaInAnimationAdapter(itemsAdapter));
    
    }
    

    You need to add dependencies to your gradle

    dependencies {
      // jCenter
      ...... 
      your curent dependencies 
      ....
      compile 'jp.wasabeef:recyclerview-animators:2.0.0'
    }
    

    Read teh doc form https://github.com/wasabeef/recyclerview-animators to install it.

提交回复
热议问题