I have a list of locations listed in a recycler view. When I press the delete icon button, the item of that button should be deleted.
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.locationTitleTextView.text = locationList[position].name
holder.coordinatesTextView.text = locationList[position].coordinateText
holder.deleteLocationButton.setOnClickListener {
locationList.removeAt(position)
notifyItemRemoved(position)
notifyItemRangeChanged(position, locationList.size)
}
}
Now the code does work in deleting the item, but the animation produced after calling notifyItemRemoved(position)
and notifyItemRangeChanged(position, locationList.size)
the animation is not as intended.
I'm not sure how to describe the animation I observed, but it went something like this. When I delete any item that is not the last item, the last item becomes invisible and then the whole item list is updated in sec.
Is there any other implementation where the animation of the removal is smooth and not rugged?