What is the use of decorating items in RecyclerView VS to edit individual bloated layouts?

Basically what the name asks, what is the point of decorating objects in recycler views, if you can achieve the same effect by editing the layout that you are inflating in the recycler view.

+4
source share
3 answers

Because you can’t always “achieve the same effect by editing the layout that you fan in the recycler” very easily.

This is especially true if you want the delimiters to ListViewbecome between the records (say, in a vertical list). In this case, not every element has a separator - neither the first nor the last do. For simple cases, you can still handle this inside the layouts themselves, hiding the separator in the layout when it is an element that should not have a separator. However, if you:

  • allow users to reorder items or

  • you use something like SortedListto store items in sorted order or

  • you dynamically add and remove items

then trying to make sure the delimiters are handled correctly is a pain, because what elements get and do not get the divider moving.

, . :

  • , ,

RecyclerView . , , CardView , , , CardView .

, , , .

+4

, , , , , . , Decorator Canvas. , , ..

. , RecyclerView " ListView" . !:-)

, - . RecyclerView LayoutManager. , , ?

RecyclerView , , , Views (so ListView, GridView, StarShapedZumaSnakeView ..): -)

+2

. , ItemDecorator.

, . , - .

ItemDecoration . , , ..

+1

Source: https://habr.com/ru/post/1619356/


All Articles