【发布时间】:2021-12-05 15:31:29
【问题描述】:
嘿,我正在使用反向 Reyclerview。我还在项目中嵌套了 Recyclerview。我想滚动到位置。首先,我将解释我的清单。
ABC
data class ABC(
val key: Int,
val value: MutableList<XYZ?>
)
XYZ
data class XYZ(
val text: Boolean? = null,
val id: String? = null
)
列表看起来像这样
ABC(0, listof( XYZ(0,"abc") ))
ABC(1, listof( XYZ(0,"abc"), XYZ(1,"qwe"), XYZ(2,"tyu") ))
ABC(2, listof( XYZ(0,"abc") ))
ABC(3, listof( XYZ(0,"abc"), XYZ(1,"qwe") ))
...... more like this
我使用 stackFromEnd 和 reverseLayout 来反转布局
binding.reycelerview.apply {
this.adapter = adapter
layoutManager = LinearLayoutManager(this.context).apply {
stackFromEnd = false
reverseLayout = true
}
}
我添加了图片看起来我的回收站视图
例如
场景1如果我想使用
reycelerview.smoothToScroll(4)
实际输出
我想在屏幕顶部显示索引 4 元素,而不是如上图所示。我正在添加预期的输出图像。
预期输出
场景 2
我想滚动到屏幕顶部的嵌套 recyerlview。我不知道该怎么做。假设我有价值去 4 索引第 2 项。
ABC(4, listof( XYZ(0,"abc"), XYZ(1,"qwe"), XYZ(2,"tyu") ))
预期输出
提前致谢。
【问题讨论】:
标签: android kotlin android-recyclerview android-adapter listadapter