How to add dividers and spaces between items in RecyclerView?

前端 未结 30 3550
清歌不尽
清歌不尽 2020-11-22 03:27

This is an example of how it could have been done previously in the ListView class, using the divider and dividerHeight parame

30条回答
  •  暖寄归人
    2020-11-22 04:09

    You can add with programaticly easily.

    If your Layout Manager is Linearlayout then you can use:

    DividerItemDecoration is a RecyclerView.ItemDecoration that can be used as a divider between items of a LinearLayoutManager. It supports both HORIZONTAL and VERTICAL orientations.

     mDividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
             mLayoutManager.getOrientation());
     recyclerView.addItemDecoration(mDividerItemDecoration);
    

    source

提交回复
热议问题