I have a RecyclerView
in which items are a LinearLayout
with several TextViews
as childs. Depending on some rules (this is decided in onBindViewHolder
), the TextViews
might be hidden away (visibility GONE) or shown.
My problem is that if I have for example 3 items (A, B and C) in the RecyclerView
with the same number of visible TextViews
and A is on top of the list, B in the middle and C at the bottom, if for example B has to show more TextViews
than before, during a brief period of time this item (B) will overlap with C since it has grown in size and has to accommodate the new visible TextViews
which were previously with visibility GONE.
Visual representation of the problem:
Desired situation
Current and undesired situation
After a bit the RecyclerView
accommodates the item correctly.
How can I avoid this from happening?
EDIT:
In one of the comments is suggested that I might have to animate and transforms the views myself. Is that necessary or is there another way of doing it? If so, how can I animate and transform the views?
EDIT 2:
Tried this answer: Animating items, but the problems persists. There's a visible delay until the RecyclerView
updates.
EDIT 3:
I am using this class (RecyclerViewCursorAdapter) as base for the adapter that populates the RecyclerView
. Aditionally, I am doing this in onResume
@Override
public void onResume()
{
super.onResume();
if(getActivity().getSupportLoaderManager().getLoader(R.id.myLoaderId) == null)
{
getActivity().getSupportLoaderManager().initLoader(R.id.myLoaderId, null, this);
}
else
{
getActivity().getSupportLoaderManager().restartLoader(R.id.myLoaderId, null, this);
}
}