2

I have to draw a curved line on the left side of recycler view ( which connect all the item in the recyclerview).But i cant get all of the position of recyclerview item to start draw my custom view.I tryed to get the x,y position inside onBindViewHolder but it not work ( i though when inside nestedscrollview it just like a tableview).So how can i get all the position of recyclerview's items after set it adapter

Here is the screen shot of what i have to do: https://imgur.com/a/C1jTNKr

shadow
  • 84
  • 10

1 Answers1

2

If your RecyclerView has hundreds of items, you shouldn't put it inside NestedScrollView or try to get any measure of all items at once.

The reason is: RecyclerView will have to measure layout for all items at once, which is totally opposite with the purpose of RecyclerView (calculate layout for item when needed) and lead to a very bad performance, very laggy or even freeze your app (if there are about 1000 items)

In your case, I think you should try to draw each path of the line inside each onBindViewHolder() as part of each item. If the logic to calculate how each draw is drawn is not too complex, I think this is an doable solution to consider

Miller Go Dev
  • 510
  • 4
  • 7
  • thank you.i put the recyclerview inside nested cause it not able to load more and only got 7-10 items.and i'm not able to get the point ( x,y) of all the item because it already load all view in the nested scroll view in the first time ( it not visible yet).but @RahulKhurana gave me a really hopeful solution.thank for your reply!!! – shadow Sep 13 '19 at 06:17