Is it possible to have the last item in a RecyclerView to be docked to the bottom if there is no need to scroll?

后端 未结 4 1182
日久生厌
日久生厌 2021-02-08 17:35

I\'m building a shopping cart RecyclerView that displays all the items in the cart in a RecyclerView, as well as it has an additional view at the bottom that summarizes the cart

4条回答
  •  悲哀的现实
    2021-02-08 18:01

    This is not an intended use case but you create an ItemDecorator and when getItemOffsets is called on the bottom view, calculate the space above it and set it as decorOffsetTop.

    Each time you add an item, you should invalidate item decor offsets so that RecyclerView will call your callback again for a new calculation.

    It won't be trivial but this should work.

提交回复
热议问题