Android Recycle View 滚动

huangapple go评论55阅读模式
英文:

Android Recycle View Scrolling

问题

以下是您要翻译的内容:

"hi I am building chat app using firebase realtime , facing issue with scrolling to last message -Bottom- when new message received , its working fine scrolling and every thing but not showing full height for the last item

here is my code

binding.items.smoothScrollToPosition(adapter.itemCount);

if any code to scroll with offset and how to calculate offset for dynamic height for message"

英文:

hi I am building chat app using firebase realtime , facing issue with scrolling to last message -Bottom- when new message received , its working fine scrolling and every thing but not showing full height for the last item

here is my code

binding.items.smoothScrollToPosition(adapter.itemCount);

if any code to scroll with offset and how to calculate offset for dynamic height for message

答案1

得分: 1

我找到了使用的解决方案:

layoutManager.stackFromEnd = true

最终的代码是:

val layoutManager = binding.items.layoutManager as LinearLayoutManager
layoutManager.stackFromEnd = true
binding.items.smoothScrollToPosition(adapter.itemCount)
英文:

I found soultion to use

layoutManager.stackFromEnd = true

final code is

 val layoutManager = binding.items.layoutManager as LinearLayoutManager
                layoutManager.stackFromEnd = true
                binding.items.smoothScrollToPosition(adapter.itemCount)

huangapple
  • 本文由 发表于 2023年2月6日 19:01:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75360453.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定