我有RecyclerView物品ImageView.我想让RecyclerView时间只显示一个项目ViewPager,在更改时拖动到边缘.谁知道如何实现这一目标?
我正在使用此来源的代码:
Android Simple RecyclerView Widget示例
唯一的区别是我没有TextView,只有ImageView.
我正在FocusLayoutManager使用RecyclerView. 一切都很好,但我一次只需要刷一项。我也尝试过LinearSnapHelper,其他人也尝试过,SnapHelperOneByOne但没有帮助。还尝试修改焦点布局管理器类本身但一切都是徒劳的。任何帮助,将不胜感激。
注意:我尝试在分配布局管理器后将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)