RecyclerView.Adapter.notifyItemMoved(0,1) scrolls screen

后端 未结 4 1613
旧巷少年郎
旧巷少年郎 2021-01-02 03:00

I have a RecyclerView managed by a LinearlayoutManager, if I swap item 1 with 0 and then call mAdapter.notifyItemMoved(0,1), the moving animation causes the screen to scroll

4条回答
  •  半阙折子戏
    2021-01-02 03:24

    Call scrollToPosition(0) after moving items. Unfortunately, i assume, LinearLayoutManager tries to keep first item stable, which moves so it moves the list with it.

提交回复
热议问题