A. Steenbergen
A. Steenbergen

Reputation: 3440

Animated list item expansion with RecyclerView?

How can I achieve this neat list item expansion effect with the Android RecyclerView?

Video

So far I was only able to find tutorials on this for the old ListView API.

Upvotes: 1

Views: 1856

Answers (1)

user4084459
user4084459

Reputation:

I'm sure there are a few ways to do such an effect, but the way that I'd do it really wouldn't have anything to do with ListView, or RecyclerView. That more has to do with the actual displaying of the items of data. What we're seeing in the video is a behavior when an item is clicked.

Here is how I'd do it: 1. Create a custom View that extends LinearLayout, RelativeLayout, or FrameLayout. 2. You essentially have 2 states, expanded state, and non-expanded state. Have the view intercept click events, and when it's clicked in non-expanded state, it animate an expand. This should automatically animate the other views in the RecyclerView down, and then animate in the new information after the growing animation is complete.

What you are asking is fairly complex, but that is the general gist of how I would do it. I'd get this working as a view by itself before I started adding it to the RecyclerView.

Upvotes: 1

Related Questions