RecyclerView LinearLayout Manager gibt im Querformat immer -1 zurück - findLastCompletelyVisibleItemPosition ()
Ich benutzefindLastCompletelyVisibleItemPosition()
, um das letzte sichtbare Element in meiner RecyclerView zu bestimmen.
Hier ist ein Codeausschnitt, wie ich mein Layout einrichte:
mRecyclerView.setHasFixedSize(true);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(getContext());
mRecyclerView.setLayoutManager(mLayoutManager);
Layout XML:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/message_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:paddingBottom="@dimen/footer_progress_bar"
android:paddingTop="16dp"
android:scrollbars="vertical" />
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:visibility="gone" />
<ProgressBar
android:id="@+id/footer_progress_bar"
android:layout_width="@dimen/footer_progress_bar"
android:layout_height="@dimen/footer_progress_bar"
android:layout_gravity="center|bottom"
android:visibility="gone" />
</FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Im Hochformat funktioniert dies einwandfrei und gibt immer die richtige Position zurück.
Im Querformat ist die zurückgegebene Position jedoch immer -1.
Meine Frage ist
Weiß jemand, warum das passiert?
Wie kann ich dies überschreiben, um die richtige Position zurückzugeben?
Oder kann jemand eine andere Lösung empfehlen, um die richtige Position des letzten Elements im Querformat zu ermitteln?