I have a fragment with a toolbar and a recyclerView inside it.
I am populating the recyclerView with dummy data and then try to show them. For some reason, the last
Use RelativeLayout as a parent of RecycerView.It's working for me.
I was facing the same issue and nether of the answers were helpful.
I solved this by adding the android:minHeight="?actionBarSize"
to CollapsingToolbarLayout
.
Maybe this will help someone.
Make sure you have layout_height
as wrap_content
for both RelativeLayout
and RecyclerView
I was having the same problem, After searching lot i found out that My parent view holding the recycleView was not properly constrained as i was using constraintLayout,
my view hierarchy was like
constraintLayout->pageViewer with tab->fragment->recyclerView
In my case pageViewer was not constrained properly
to solve this please check weather the parent is properly aliened or constrained
I was facing the same issue and what I did is created a LinearLayout
and placed my RecyclerView
inside it and it solved my issue.I hope this will solve other issue as well.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/companyLabelView">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/companiesRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_8dp"
android:layout_marginStart="@dimen/_8sdp"
android:layout_marginLeft="@dimen/_8sdp"
android:layout_marginTop="@dimen/_8sdp"
android:layout_marginEnd="@dimen/_8sdp"
android:layout_marginRight="@dimen/_8sdp"
android:layout_marginBottom="@dimen/_8sdp"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:spanCount="3"
tools:itemCount="10"
tools:listitem="@layout/company_item_view" />
</LinearLayout>
add android:layout_gravity="top"
to recyclerview
. if this didn't work add android:layout_gravity="fill_verticle"