Xamarinandroid Component Tutorial Setting custom element animations (i)
If you don't have the animation effect you need in recyclerviewanimators.animators, you can customize one. At this point, you need to have the custom animation inherit the Baseitemanimator abstract class.
"Example 1-2", based on the Recylerviewanimatorsitemanimator project, implements a transparent animation effect when the Recylerview child element is added/removed. The following steps are described:
(1) Create a class file named Alphaanimator.
(2) Open the AlphaAnimator.cs file for transparency animation. The code is as follows:
Using system;using system.collections.generic;using system.linq;using system.text;using Android.App;using Android.content;using android.os;using android.runtime;using android.support.v4.view;using Android.support.v7.widget;using android.views;using android.widget;using recyclerviewanimators.animators; Namespace recylerviewanimatorsitemanimator{public class Alphaanimator:baseitemanimator {public Alphaanima Tor () {}//When adding child elements protected override void Animateaddimpl (Recyclerview.viewholder holder) {viewcompat.animate (Holder). Itemview). Alpha (1). Setduration (addduration). Start (); }//delete child element when called animation protected override void Animateremoveimpl (Recyclerview.viewholder holder) { Viewcompat.animate (Holder. Itemview). Setduration (removeduration). Alpha (0). Start (); } }}
Xamarinandroid Component Tutorial Set custom element animation (i)