Original Java Library: https://github.com/wasabeef/recyclerview-animators
RecyclerView Animators is an Android library that allows developers to easily create RecyclerView with animations.
Please feel free to use this.
- Animate addition and removal of
ItemAnimator
- Appearance animations for items in
RecyclerView.Adapter
install via Package Manager
PM> Install-Package Xamarin.RecyclerView.Animators
or search for it in Manage NuGet Packages in Visual Studio
import the namespace
using JP.Wasabeef.Recyclerview.Adapters;
Set RecyclerView ItemAnimator.
RecyclerView recyclerView = FindViewById<RecyclerView>(R.id.list);
recyclerView.SetItemAnimator(new SlideInLeftAnimator());
RecyclerView recyclerView = FindViewById<RecyclerView>(R.id.list);
SlideInUpAnimator animator = new SlideInUpAnimator(new OvershootInterpolator());
recyclerView.SetItemAnimator(animator);
Please use the following
NotifyItemChanged(int)
NotifyItemInserted(int)
NotifyItemRemoved(int)
NotifyItemRangeChanged(int, int)
NotifyItemRangeInserted(int, int)
NotifyItemRangeRemoved(int, int)
If you want your animations to work, do not rely on calling
NotifyDataSetChanged()
; as it is the RecyclerView's default behavior, animations are not triggered to start inside this method.
public void Remove(int position) {
mDataSet.Remove(position);
NotifyItemRemoved(position);
}
public void Add(string text, int position) {
mDataSet.Add(position, text);
NotifyItemInserted(position);
}
You can change the durations.
recyclerView.GetItemAnimator().SetAddDuration(1000);
recyclerView.GetItemAnimator().SetRemoveDuration(1000);
recyclerView.GetItemAnimator().SetMoveDuration(1000);
recyclerView.GetItemAnimator().SetChangeDuration(1000);
Change the interpolator.
SlideInLeftAnimator animator = new SlideInLeftAnimator();
animator.SetInterpolator(new OvershootInterpolator());
recyclerView.SetItemAnimator(animator);
LandingAnimator
ScaleInAnimator
, ScaleInTopAnimator
, ScaleInBottomAnimator
ScaleInLeftAnimator
, ScaleInRightAnimator
FadeInAnimator
, FadeInDownAnimator
, FadeInUpAnimator
FadeInLeftAnimator
, FadeInRightAnimator
FlipInTopXAnimator
, FlipInBottomXAnimator
FlipInLeftYAnimator
, FlipInRightYAnimator
SlideInLeftAnimator
, SlideInRightAnimator
, OvershootInLeftAnimator
, OvershootInRightAnimator
SlideInUpAnimator
, SlideInDownAnimator
Set RecyclerView ItemAnimator.
RecyclerView recyclerView = FindViewById<RecyclerView>(R.id.list);
MyAdapter adapter = new MyAdapter();
recyclerView.SetAdapter(new AlphaInAnimationAdapter(adapter));
Change the durations.
MyAdapter adapter = new MyAdapter();
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
alphaAdapter.SetDuration(1000);
recyclerView.SetAdapter(alphaAdapter);
Change the interpolator.
MyAdapter adapter = new MyAdapter();
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
alphaAdapter.SetInterpolator(new OvershootInterpolator());
recyclerView.SetAdapter(alphaAdapter);
Disable the first scroll mode.
MyAdapter adapter = new MyAdapter();
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
scaleAdapter.SetFirstOnly(false);
recyclerView.SetAdapter(alphaAdapter);
Multiple Animations
MyAdapter adapter = new MyAdapter();
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
recyclerView.SetAdapter(new ScaleInAnimationAdapter(alphaAdapter));
AlphaInAnimationAdapter
ScaleInAnimationAdapter
SlideInBottomAnimationAdapter
SlideInRightAnimationAdapter
, SlideInLeftAnimationAdapter
Daichi Furiya (Wasabeef) - dadadada.chop@gmail.com
Xamarin bindings by Gabriele Coquillard (kokiddp) - gabriele.coquillard@gmail.com
Any contributions are welcome!
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.