RecyclerView remove divider / decorator after the last item

前端 未结 9 2117
礼貌的吻别
礼貌的吻别 2020-12-07 17:46

I have a quite simple RecyclerView.
This is how I set the divider:

DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), DividerI         


        
9条回答
  •  半阙折子戏
    2020-12-07 17:54

    Create your own Divider class (Example here)

    In the code that draws the divider, check first if you are drawing the divider for the last item in the list. If so, don't draw it.

    Just be aware that if you override OnDrawOver it draws on TOP of your view including scrollbars etc. Best to stick to OnDraw. Lots of examples on Google but this is a good tutorial on creating your own decorators.

提交回复
热议问题