When do we use the recyclerView.setHasFixedSize?

前端 未结 2 1925
旧巷少年郎
旧巷少年郎 2020-12-14 15:41

here\'s the thing: Anybody know the setHasFixedSize method? some says that it allows for optimizations if all items are of the same size, and in RecyclerView class from andr

2条回答
  •  感动是毒
    2020-12-14 15:52

    setHasFixedSize() is used to let the RecyclerView keep the same size.

    This information will be used to optimize itself.

    Here is reference url

    http://antonioleiva.com/recyclerview/

    Example:

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    recyclerView.setHasFixedSize(true);
    

提交回复
热议问题