我看到了从底部到顶部RecyclerView显示的某种方法ViewHolders.现在,我找不到它的任何地方(后经历时间的一半RecyclerView,RecyclerAdapter,LayoutManager...).
And*_*dEx 78
难道LinearLayoutManager.setStackFromEnd(true)你正在寻找?
编辑
事实证明了这LinearLayoutManager.setReverseLayout(true)一点.无论哪种方式,读者可能想要尝试每种方法和两者的组合以获得所需的效果.
这是科特林的解决方案
val llm = LinearLayoutManager(this)
llm.stackFromEnd = true // items gravity sticks to bottom
llm.reverseLayout = false // item list sorting (new messages start from the bottom)
rv_chat_history.layoutManager = llm
Run Code Online (Sandbox Code Playgroud)
或者,如果您喜欢apply方法:
recycler.apply {
layoutManager = LinearLayoutManager(this).apply {
stackFromEnd = true
reverseLayout = true
}
}
Run Code Online (Sandbox Code Playgroud)
您可以通过在xml代码中添加两行来完成此任务。
app:stackFromEnd="true"
app:reverseLayout="true"
Run Code Online (Sandbox Code Playgroud)
这将与所有聊天应用程序一起使用。
如果您使用的是LinearLayoutManager,请将第三个参数(reverseLayout)设为 false
LinearLayoutManager linearLayoutManager =
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31391 次 |
| 最近记录: |