Margin/padding in last Child in RecyclerView

前端 未结 9 977
醉话见心
醉话见心 2021-01-30 05:56

I\'m trying to add Padding/Margin Bottom in the last row and Padding/Margin Top in the first row. I can not do it in the item xml as it would affect all of my Children.

I

9条回答
  •  执笔经年
    2021-01-30 06:40

    This issue is even easier to solve. You can apply necessary padding to the RecylerView itself and set clipToPadding to false, otherwise, the padding will chop off your scrolling area. Here is an example

    
    

    See the padding will add 4dp on all sides including top and bottom. Then the clipToPadding parameter makes sure your child items are not chopped off. Now, add 4dp padding to all sides for your child items, and you are good to go. In total you get 8dp padding on sides and between items.

提交回复
热议问题