Open zeroarst opened 7 years ago
Actually I use another way to get children positions, I store the position in the ViewHolder when binding data. Just wondering if there any existing way to do it.
Hi. Unfortunately, there is no existing way to handle this kind of problem. I think your solution is correct, I would do the same thing if I need to implement group/child position specific item decorations.
Hi, currently I am facing the same problem and was wondering how to access those positions stored in the ViewHolder from within the Decorator?
Nevermind, already found the solution. Wasn't looking into RecyclerView. Now found its method getChildViewHolder(view)
I am trying draw borders for groups. I found that the views' orders in the RecyclerView are not always right.
Assume there are 3 album groups, the second one is expanded, 3 items are showing, and I click second one to collapse, observer what is in
RecyclerView.ItemDecoration
onDraw
. In the list, in theory, the order should be: (In parenthesis, g isgetPackedPositionGroup
, c isgetPackedPositionChild
).However, in reality, I see
No order is weird, which I don't know why. but does not matter in my question. My question is that I cannot get correct child position when collapsing. I still can get correct group position against those children items. I wonder is there any way to still get the right child position in this case? I know that I still can call
RecyclerView.getChildLayoutPosition
to get the right position, because the changes not reflects to adapter yey. But this does not help. I need to know children's position in the group. Maybe a a method likegetPackedLayoutPositionChild
?Actually I use another way to get children positions, I store the position in the ViewHolder when binding data. Just wondering if there any existing way to do it.