How to add dividers and spaces between items in RecyclerView?

前端 未结 30 2809
清歌不尽
清歌不尽 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:32

    A really easy solution is to use RecyclerView-FlexibleDivider

    Add dependency:

    compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'
    

    Add to your recyclerview:

    recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(context).build());
    

    And you're done!

提交回复
热议问题