2017-03-01 2 views
0

を開始し、私は解決策を見つけた:Android-> RecyclerView - >移動アニメーションがあまりにも速く

は、アニメーションの継続時間に等しいcallメソッドのsetRemoveDuration(長期)と設定した時間 (私を必要としますケース4000)

私は、DefaultItemAnimatorを使用してRecyclerViewのシンプルなアニメーションを作成しました。私のアニメーションは、右側に取り除かれている要素をスライドさせます。アニメーションの移動が速すぎることを除いて、すべてがうまく動作します。スライドアニメーションが終了すると、どのように/どこで手動でロックして起動できますか(adnimationMoved)

movie in youTube

マイカスタムデフォルトのアニメーター

public class CustomMainDefaultAnimator extends DefaultItemAnimator { 
    Context context; 

    public CustomMainDefaultAnimator(Context context) { 
     this.context = context; 
     setSupportsChangeAnimations(false); 
    } 

    @Override 
    public boolean animateRemove(RecyclerView.ViewHolder holder) { 
     Animation animation = new CustomAnimation(context).slideOut(4000); 
     holder.itemView.startAnimation(animation); 
     return super.animateRemove(holder); 
    } 

    @Override 
    public boolean animateAdd(RecyclerView.ViewHolder holder) { 
     Animation animation = new CustomAnimation(context).slideIn(4000); 
     holder.itemView.startAnimation(animation); 
     return super.animateAdd(holder); 
    } 
} 

答えて

0
あなたはクラスのアニメーターの方法 isRunning()を使用し、それが終了するまで最初のアニメーションを見て、その方法 isRunning()がfalseを返した後、開始することができます

あなたの次のアニメーション。

+0

私はアニメーションを開始しません、自動的に起動するので、私は最初にデフォルトの移動アニメーションをブロックする必要があります。 – Grzegorz

+0

havent試してみませんか?まずは、ホルダーの部分をするpostDelayedアクションを置くことです。 itemView.startAnimation(アニメーション); return super.animateAdd(holder); 4秒遅れで – Ivan

+0

私はもっと良い例を書くためにできるだけ早く試していきます。少し試してみてください。 – Ivan

関連する問題