RecyclerView recalculate WRAP_CONTENT

Viewed 14518

With version 23.2 we can now use WRAP_CONTENT for recyclerView height, which is great. I am doing this, however I want to recalculate the height after an item is added (or removed) to the adapter (thus increasing or decreasing the height).

My particular RecyclerView is starting with 1 item, and then adding items as the user makes selection. So I need the RecyclerView layout to increase in height, up to a point. Ideally this would happen with a smooth animation when the list increases or decreases.

How can we make it WRAP_CONTENT after it has been laid out?

Tried:

recyclerview.requestLayout();

recyclerview.invalidate();
4 Answers
Related