Last Item in recyclerview is cut off
I tried all the available option from most of possible site but I didn't get the solution. Then, I think can I use bottom padding? And Yes, It's work for me.
I am sharing the code to you. Nothing more attribute required other than height, width & padding.
<android.support.v7.widget.RecyclerView
android:id="@+id/your id name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="?attr/actionBarSize"
app:layout_constraintTop_toBottomOf="@+id/your field" />
Your RecyclerView
is not properly constrained. You can either use 0dp
(MATCH_CONSTRAINT
) for the height and use all available space:
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
or if you want to keep it as wrap_content
you will need to set app:layout_constrainedHeight="true"
attribute to enforce the constraints:
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:visibility="visible"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
1)The View of Recyclerview must be properly constrained. (by ConstraintLayout or any other layout parameters).
2)The Last item occupies the space inside the RecyclerView, hence use Padding. (e.g android:paddingBottom="50dp")
3)Use android:clipToPadding="false" in XML.