I\'m having some trouble understanding setHasFixedSize()
. I know that it is used for optimization when the size of RecyclerView
doesn\'t change, fr
If we have a RecyclerView
with match_parent
as height/width, we should add setHasFixedSize(true)
since the size of the RecyclerView
itself does not change inserting or deleting items into it.
setHasFixedSize should be false if we have a RecyclerView with wrap_content
as height/width since each element inserted by the adapter could change the size of the Recycler
depending on the items inserted/deleted, so, the size of the Recycler
will be different each time we add/delete items.
To be more clear, if we use
We can use my_recycler_view.setHasFixedSize(true)
We should use my_recycler_view.setHasFixedSize(false)
, this applies if we also use wrap_content
as width