doorman doorman - 1 year ago 327
Android Question

Animate selected item in MvxRecyclerView

I am using MvxRecyclerView and I want to animate the selected item in the list. How can I get a reference to the selected item view? Should I use TouchDelegate?

Answer Source

You should be able to get the view reference through the RecyclerAdapter.

Implementation Example:

Create a custom MvxRecyclerAdapter to deal with your desired animation.

public class SelectedAnimatorRecyclerAdapter : MvxRecyclerAdapter
    public SelectedAnimatorRecyclerAdapter(IMvxAndroidBindingContext bindingContext)
          : base(bindingContext)

    public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        base.OnBindViewHolder(holder, position);

        holder.ItemView.Click += (s, e) =>

    void SetAnimation(View viewToAnimate)
        ScaleAnimation anim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f);
        anim.Duration = 2000;

Implement adapter in your MvxRecyclerView

var recyclerView = view.FindViewById<MvxRecyclerView>(Resource.Id.my_recycler_view);
recyclerView.Adapter = new SelectedAnimatorRecyclerAdapter((IMvxAndroidBindingContext)BindingContext);

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download