How to programmatically snap to position on Recycler view with LinearSnapHelper

前端 未结 3 1110
执念已碎
执念已碎 2021-02-07 05:40

I have implemented a horizontal recyclerView with LinearSnapHelper, to implement a UI input that selects a particular configuration. Kinda like the old school number picker/sele

3条回答
  •  没有蜡笔的小新
    2021-02-07 06:14

    Try calling smoothScrollToPosition on the RecyclerView object, and passing the position index (int)

    mRecyclerView.smoothScrollToPosition(position);
    

    Worked for me with a LinearLayoutManager and LinearSnapHelper. It animates the initial scroll, but at least snaps the item in position.

    This is my first post on the stack, hope it helps :)

提交回复
热议问题