Large gap forms between RecyclerView items when scrolling down

前端 未结 9 2006
别跟我提以往
别跟我提以往 2020-12-23 20:16

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 D

9条回答
  •  渐次进展
    2020-12-23 20:53

    Luksprog's answer to Gabriele Mariotti's answer works.

    According to the doc

    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.

    Due to this change, make sure to double check the layout parameters of your item views: previously ignored layout parameters (such as MATCH_PARENT in the scroll direction) will now be fully respected.

    In your item layout you have to change:

    android:layout_height="match_parent"
    

    with

    android:layout_height="wrap_content" 
    

提交回复
热议问题