Work With StaggeredGridLayotManager?

坚强是说给别人听的谎言 提交于 2019-12-24 06:20:44

问题


I want to use a StaggeredGridLayoutManager to have a vertical list with two columns and each row has 3 parts. What exactly should I do?


回答1:


try this to use StaggeredGridLayotManager

private StaggeredGridLayoutManager gaggeredGridLayoutManager;
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);    
gaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager)

here is the tutorial link working with StaggeredGridLayotManager




回答2:


suppose you want to attach it to a recyclerview, you can add add like this

  StaggeredGridLayoutManager staggeredGridLayoutManager=new 
  StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(staggeredGridLayoutManager);

where recyclerView is the RecyclerView object



来源:https://stackoverflow.com/questions/46190573/work-with-staggeredgridlayotmanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!