将recyclerview焦点转移到列表中的最后一个元素 [英] Shift recyclerview focus to last element in the list

查看:594
本文介绍了将recyclerview焦点转移到列表中的最后一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用recyclerview在聊天窗口中显示消息.但是,在编辑新消息时,回收者视图的焦点应放在最后一个元素上.我希望可以通过某种方式将recyclerview的焦点转移到最后一个元素,而不是第一个元素.

I am using recyclerview to display messages in a chat window. However, when a new message is being edited, the recycler view focus should be on the last element. I expect there would be some way to shift the focus of a recyclerview to last element instead of first.

推荐答案

使用recyclerView.smoothScrollToPosition(position);

位置 是您插入的最后一项的索引.这会将RecyclerView焦点移到最后一个元素上.

position is your index of last item inserted. This will move your the RecyclerView focus on the last element.

这篇关于将recyclerview焦点转移到列表中的最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆