要在列表视图中启用聊天式滚动,我们可以使用以下属性:
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
....
android:stackFromBottom="true"
android:transcriptMode="normal" />
这是创建聊天的简单而有效的方式。
我们如何使用回收者视图做同样的事情?我没有找到任何简单的解决方案。
问候,
RecyclerView 有一个stackFromEnd
属性。
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recyclerView"
android.support.v7.recyclerview:stackFromEnd ="true"/>
或者你可以通过代码来完成
mLayoutManager = new LinearLayoutManager(getActivity());
mLayoutManager.setReverseLayout(true);
mLayoutManager.setStackFromEnd(true);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)