Interestingly, RecyclerView knows if its size (width and height dimensions) depends on the contents of the adapter to avoid costly layout operations. If the RecyclerView knows in advance that its size does not depend on the contents of the adapter, it will skip checking if its size should be changed every time an element is added or removed from the adapter. This is especially important since insertion of deletion elements can occur very often.
If the size of the RecyclerView (of the RecyclerView itself) ...
... does not depend on the contents of the adapter:
mRecyclerView.setHasFixedSize(true);
... depends on the contents of the adapter:
mRecyclerView.setHasFixedSize(false);
If you check the RecyclerView class , you will see it in more detail, because at the moment mHasFixedSize is not used in many places in this class.
Setting it as true does not mean that the size of the RecyclerView is fixed, it simply means that it will not change due to changes in the contents of the adapter. For example, the size of a RecyclerView may change due to the resizing of its parent.
Sotti Nov 20 '16 at 5:31 on 2016-11-20 17:31
source share