小编Moi*_*han的帖子

使用 FocusLayoutManager 捕捉 RecyclerView 以一次滚动一项

我正在FocusLayoutManager使用RecyclerView. 一切都很好,但我一次只需要刷一项。我也尝试过LinearSnapHelper,其他人也尝试过,SnapHelperOneByOne但没有帮助。还尝试修改焦点布局管理器类本身但一切都是徒劳的。任何帮助,将不胜感激。

  1. FocusLayoutManager的链接

  2. SnapHelperOneByOne的链接

  3. FocusLayoutManagerLibrary的链接

注意:我尝试在分配布局管理器后将SnapHelper其附加到。RecyclerView

 val focusLayoutManager = FocusLayoutManager.Builder()
        .focusOrientation(FocusLayoutManager.FOCUS_TOP)
        .isAutoSelect(true)
        .maxLayerCount(1)
        .setOnFocusChangeListener { focusdPosition, lastFocusdPosition -> }
        .build()
myRecycler.layoutManager = focusLayoutManager
Run Code Online (Sandbox Code Playgroud)

使用 Snap Helper 也没有帮助,并且会使滚动滞后(抽搐)

val mySnapHelper = SnapHelperOneByOne()
mySnapHelper.attachToRecyclerView(myRecycler)
Run Code Online (Sandbox Code Playgroud)

java android android-layout kotlin android-recyclerview

1
推荐指数
1
解决办法
607
查看次数