본문 바로가기
Android

RecyclerView 하단 divider 깜빡임 | RecyclerView bottom divider blinking

by kkong93 2024. 3. 26.
반응형

Finally got it!

Yet another stupid mistake, it's not complicated at all, I kept thinking, why I'm having this problem only on this activity, but not my previous one, and I suddenly realized that the layout in the two activities are different, turns out I set the RecyclerView's height to wrap_content, so I suppose what happened is that, the layout told the system to wrap the content in the RecyclerView, and when you delete an item, it's technically not there anymore, so, even though I have animations for the deleted item, the item is removed immediately from the layout's level, that's why it seems like Android adjusted the RecyclerView's height first, and then delete the item, what actually happened is, since RecyclerView is set to wrap_content, it removes the position of the view(item) immediately after delete, not after the animation, and that's why it looks like a blink.

Anyways, the solution is just simply to change the RecyclerView's height from wrap_contentto any other value, if you are using ConstraintLayout like I did, just change the height to 0dp, then constraint the RecyclerView to something else, or the edge.

Thanks to everyone who tried to help me solve my problem though, I admit this is one of the stupidest yet frustrating problems I ever had.

I believe there're others who also encountered the same problem, so just go and check if the height is set to wrap_content.

 

 

Constraint Layout에서 recyclerview를 사용할떄 보통 height 0dp를 주는데 item이 변경될때 마지막 divider가 깜빡 거리는 현상이 발생된다. (마지막 아이템일때 divider안보이게 세팅) 

단순히 0dp를 wrap_content으로 변경해주면 해결된다.

 

 


참고 사이트 : 

https://stackoverflow.com/questions/46270791/recyclerview-last-item-blinks-every-time-an-item-is-removed

 

 

RecyclerView last item blinks every time an item is removed

I'm using a cursor loader with the RecyclerView, and everything else works just fine except every time I remove an item from the RecyclerView, the last item blinks, like this last item blinks my c...

stackoverflow.com

 

 

반응형

댓글