Code Monkey home page Code Monkey logo

xamarin.recyclerview.animators's Introduction

Xamarin bindings for RecyclerView Animators

Original Java Library: https://github.com/wasabeef/recyclerview-animators

NuGet NuGet License

RecyclerView Animators is an Android library that allows developers to easily create RecyclerView with animations.

Please feel free to use this.

Features

  • Animate addition and removal of ItemAnimator
  • Appearance animations for items in RecyclerView.Adapter

Demo

ItemAnimator

Adapters

How do I use it?

Setup

Nuget

install via Package Manager

PM> Install-Package Xamarin.RecyclerView.Animators

or search for it in Manage NuGet Packages in Visual Studio

Namespace

import the namespace

using JP.Wasabeef.Recyclerview.Adapters;

ItemAnimator

Step 1

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);

Step 2

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);
}

Advanced Step 3

You can change the durations.

recyclerView.GetItemAnimator().SetAddDuration(1000);
recyclerView.GetItemAnimator().SetRemoveDuration(1000);
recyclerView.GetItemAnimator().SetMoveDuration(1000);
recyclerView.GetItemAnimator().SetChangeDuration(1000);

Advanced Step 4

Change the interpolator.

SlideInLeftAnimator animator = new SlideInLeftAnimator();
animator.SetInterpolator(new OvershootInterpolator());
recyclerView.SetItemAnimator(animator);

Animators

Cool

LandingAnimator

Scale

ScaleInAnimator, ScaleInTopAnimator, ScaleInBottomAnimator
ScaleInLeftAnimator, ScaleInRightAnimator

Fade

FadeInAnimator, FadeInDownAnimator, FadeInUpAnimator
FadeInLeftAnimator, FadeInRightAnimator

Flip

FlipInTopXAnimator, FlipInBottomXAnimator
FlipInLeftYAnimator, FlipInRightYAnimator

Slide

SlideInLeftAnimator, SlideInRightAnimator, OvershootInLeftAnimator, OvershootInRightAnimator
SlideInUpAnimator, SlideInDownAnimator

RecyclerView.Adapter

Step 1

Set RecyclerView ItemAnimator.

RecyclerView recyclerView = FindViewById<RecyclerView>(R.id.list);
MyAdapter adapter = new MyAdapter();
recyclerView.SetAdapter(new AlphaInAnimationAdapter(adapter));

Advanced Step 2

Change the durations.

MyAdapter adapter = new MyAdapter();
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
alphaAdapter.SetDuration(1000);
recyclerView.SetAdapter(alphaAdapter);

Advanced Step 3

Change the interpolator.

MyAdapter adapter = new MyAdapter();
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
alphaAdapter.SetInterpolator(new OvershootInterpolator());
recyclerView.SetAdapter(alphaAdapter);

Advanced Step 4

Disable the first scroll mode.

MyAdapter adapter = new MyAdapter();
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
scaleAdapter.SetFirstOnly(false);
recyclerView.SetAdapter(alphaAdapter);

Advanced Step 5

Multiple Animations

MyAdapter adapter = new MyAdapter();
AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
recyclerView.SetAdapter(new ScaleInAnimationAdapter(alphaAdapter));

Adapters

Alpha

AlphaInAnimationAdapter

Scale

ScaleInAnimationAdapter

Slide

SlideInBottomAnimationAdapter
SlideInRightAnimationAdapter, SlideInLeftAnimationAdapter

Developed By

Daichi Furiya (Wasabeef) - [email protected]

Xamarin bindings by Gabriele Coquillard (kokiddp) - [email protected]

Contributions

Any contributions are welcome!

License

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.

xamarin.recyclerview.animators's People

Contributors

kokiddp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

bardasoft

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.