I have a fragment that has a recycler view and a layout containing an edit text at the bottom. The edit text has min height of 50dp and max of 100dp. When I have scrolled to the last item in the recycler view, I want the recycler view to be pushed above, instead of the edit text going over the recycler view. Also, when I click the edit text, the recycler view does not display the last message
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.fragments.ChatMessageFragment">
`The Recycler View'
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvChatMessage"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/constraintLayoutEditTextHolder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
`Layout that holds the edit text'
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayoutEditTextHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rvChatMessage">
<ImageView
android:id="@+id/ivProfilePicSender"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginStart="8dp"
android:src="@drawable/profilepic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/ivSendMessage"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="8dp"
android:src="@drawable/send_24px"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:id="@+id/editTextChatMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="@drawable/et_box"
android:ems="10"
android:hint="Message @john_doe"
android:inputType="textMultiLine"
android:maxHeight="100dp"
android:minHeight="50dp"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ivSendMessage"
app:layout_constraintStart_toEndOf="@+id/ivProfilePicSender"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
The constraint layout that the edit text is in is already constrained to the recycler view.
If you want the Recyclerview to be pushed above, you should set it to be above the 'Layout that contains the edit text'.
Assuming your parent layout is RelativeLayout
this should work. let me know if it helps