There are several related posts here, but none are quite the same situation/none of the solutions have worked for me.
I have a RecyclerView that loads in some data from Firebase. I'm using a custom adapter. The issue is that when the view loads in, it loads in at the middle of the RecyclerView. I then would have to scroll up to the top manually.
My layout is very simple:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/grey"
android:layout_marginBottom="50dp"
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycler_view_feed"
android:layout_marginTop="10dp"
>
</android.support.v7.widget.RecyclerView>
</LinearLayout>
After loading in my custom objects from Firebase, I set up the RecyclerView like this (this is in a method being called from onCreateView (it's a fragment)):
CompleteWorkoutRecyclerAdapter adapter = new CompleteWorkoutRecyclerAdapter(list, getContext(),
getActivity());
mRecyclerView.setAdapter(adapter);
mRecyclerView.setHasFixedSize(false);
linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true);
mRecyclerView.setLayoutManager(linearLayoutManager);
I've tried these things to fix the issue, with no luck:
linearLayoutManager.scrollToPosition(0);
and
mRecyclerView.scrollToPosition(0);
and
android:focusableInTouchMode="true"
Thanks for reading. If you guys need any more code I can post whatever you need