首页 > 解决方案 > RecyclerView smoothScrollToPosition(lastItem) 滚动到最后一个项目部分可见的底部

问题描述

我正在处理聊天类型屏幕,其中在列表中添加了新的文本消息项,并且 recyclerView 滚动到列表的最后一个位置,但最后一项是部分可见的,并且当键盘打开时不会滚动到底部。我已经添加了

 android:layout_width="match_parent"
            android:gravity="top"
            android:layout_gravity="fill_vertical"
            android:windowSoftInputMode="adjustResize"
            android:clipToPadding="false"
            android:layout_height="match_parent"
            app:layout_constrainedHeight="true"
            app:layout_scrollFlags="scroll|enterAlways"
           app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:layout_marginBottom="@dimen/margin_5"

到回收站视图。我也尝试过使用 recyclerView.layoutMangaer.smoothScrollToPosition, ScrollBy() 方法,并且还使用了大约 300 毫秒的延迟来滚动。没有任何效果。

将不胜感激一些帮助。谢谢。

标签: androidkotlinandroid-recyclerviewsmooth-scrollinglinearlayoutmanager

解决方案


推荐阅读