我正试图让我的recyclerview从底部开始
Make Recycler View show rows from bottom
根据这个答案,我都尝试过这两个
mMessageRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mMessageRecycler.setAdapter(mMessageAdapter);
并且使用XML中的reverseLayout
app:stackFromEnd="true"
app:reverseLayout="true"
但是他们都不是让recyclerview从底部开始...仍然从顶部开始
这是我的整个布局:
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/challengeroom_recycler"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@null"
app:layout_constraintBottom_toTopOf="@id/challengeroom_et_sendmessage"
app:layout_constraintTop_toBottomOf="@+id/guideline1"
app:layout_constraintRight_toRightOf="@+id/vertical_guideline_75percent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="16dp"
android:layout_marginBottom="16dp"
app:stackFromEnd="true"
app:reverseLayout="true"/>
请尝试此代码
LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);;
layoutManager.setStackFromEnd(true)
mMessageRecycler.setLayoutManager(layoutManager)