티스토리 뷰
RecyclerView에서 스크롤을 내릴 때 기대하지 않은 큰 간격이 발생할 수 있습니다. ~~ListView에서는 없던 일인데~~
스크롤 내리기 전에는 멀쩡했는데 내렸다 올려보니까 아이템들끼리 너무 내외하는 상황에 당황했어요. 🙁
역시 답은 StackOverflow에 있었습니다.
stackoverflow.com/questions/35817610/large-gap-forms-between-recyclerview-items-when-scrolling-down
Large gap forms between RecyclerView items when scrolling down
I'm making a ToDo list app, and while testing it, for some reason, a huge gap forms between the items whenever I try to scroll down. It always happens whenever I Drag and Drop the items, but I don'...
stackoverflow.com

With the release 2.3.0 there is an exciting new feature to the LayoutManager API: auto-measurement! This allows a RecyclerView to size itself based on the size of its contents. >This means that previously unavailable scenarios, such as using WRAP_CONTENT >for a dimension of the RecyclerView, are now possible. You’ll find all built in LayoutManagers now support auto-measurement.
요약해보자면 2.30 release부터 auto-measurement가 적용되기 시작합니다. RecyclerView 자체적으로 간격을 조정할 수 있게 된다는 건데요. 기존에 무시됐던 아이템 레이아웃 내의 match_parent가 그대로 반영됩니다.
따라서 의도하지 않았던 경우라면 RecyclerView에 들어갈 item들의 레이아웃 height를 wrap_content로 변경하면 스크롤 다운시의 large gap 현상을 없앨 수 있습니다. parent layout도 동일하게 wrap_content로 설정해주어야 합니다.
'ANDROID' 카테고리의 다른 글
| 뷰 결합으로 findViewById와 작별하기🖐 (0) | 2021.04.16 |
|---|---|
| Volley 에서 Retrofit2 로 통신 교체하기 (2) | 2021.04.04 |
| null object reference 오류 (0) | 2021.03.25 |
| OnClickListener에서 intent (0) | 2021.03.19 |
| dependency추가해서 아이디/비밀번호 input 예쁘게! (0) | 2021.03.11 |