老是忘记,记录一下。
在layoutManager里面设置永远从底部
layoutManager.setStackFromEnd(true);
但是会出现数据不满一页时,数据是从底部挤上去的。这么解决呢?只要在recycleview的外层包一层布局,撑满全屏,recycleview则高度设置为包裹内容即可,比如我这边的就是最外面报了一个刷新布局
<cn.sheng.tkrefreshlayout.TwinklingRefreshLayout
android:id="@+id/refresh_chat"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:tr_enable_loadmore="false">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_chat_msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp" />
</cn.sheng.tkrefreshlayout.TwinklingRefreshLayout>
网友评论