Search code examples
androidandroid-recyclerviewandroid-animationpersistentmeasurement

Persistent animation for RecyclerView childs


I have a RecyclerView with setReverseLayout to true (chat layout). chat screen downloaded from web

Say i click on the item at 2 position (remember its layout is reversed) and call

notifyItemChanged(2[position])

In onBindViewHolder i make some views visible on that clicked item, so its height will change, and when RecyclerView would measure its children it would realize that it should move some items around to make that items height change appear engaging )). DefaultItemAnimator takes care of it, but it moves all children below "U are??? Omg thank u" item downwards. As my layout is reversed i would like all items above that clicked item to animate and move upwards. Is it possible??


Solution

  • After investigating RecyclerView and LinearLayoutManager codes , you should simply call

    setStackFromEnd(boolean stackFromEnd)

    with true. )