How to implement horizontal gridlayoutmanager

前端 未结 2 1904
暖寄归人
暖寄归人 2020-12-14 18:07

How to implement horizontal gridlayoutmanager with recyclerview. Fixed row count. and horizontal scroll. Like this...

        gridLayoutManager = ne         


        
2条回答
  •  情歌与酒
    2020-12-14 18:44

    1. Implement RecyclerAdapter, ViewHolder.
    2. Instantiate RecyclerAdapter, set its' adapter.
    3. Specify ROWSCOUNT (there are 3 rows on your picture): GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), ROWSCOUNT, GridLayoutManager.HORIZONTAL, false);

    4. Set layout manager: recyclerView.setLayoutManager(gridLayoutManager);

    5. Show your recycler view setContentView(recyclerView);

    I've prepared a sample for you, check it out

提交回复
热议问题