Recyclerview scrollen nach oben nach dem Aufruf notifydatasetchanged

Habe ich eine horizontale recyclerview (mit einem LinearLayoutManager) und es ' s child-Element hat eine Bildansicht verpackt in einem relativelayout. Die recyclerview hat drei horizontale Zeilen, die untergeordnete Elemente. Wenn die recyclerview gescrollt ist, ich aktualisiere den Datensatz mit der Antwort von einem http-Aufruf und Aufruf notifydatasetChanged in der http-Antwort-Rückruf. Wenn die recyclerview Kind-Element Höhe und Breite sind Feste Werte (ZB. 150dp, 84dp) die recyclerview verhält sich wie vorgesehen, D. H., lädt die neuen Elemente und bleibt an der gleichen scroll-position aber wenn ich die Höhe und Breite der recyclerview Kind-Element als match_parent und wrap_content, die recyclerview ist vollständig aktualisiert und blättert auf die erste position. Warum ist das passiert?
Hinweis: ich habe ähnliche Fragen auf, SO-und keiner von Ihnen bieten eine brauchbare Lösung.

main_layout

<android.support.v7.widget.RecyclerView
    android:id="@+id/grid_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="110dp"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="80dp"
    android:background="@color/transparent"
    android:outlineProvider="bounds"
    android:elevation="8dp"
    android:padding="0dp"
    android:scrollbars="none" />
....

recycler_view_child_item

<RelativeLayout      xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="0dp">
<ImageView
    android:id="@+id/thumbnail"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:adjustViewBounds="true"
    android:maxWidth="126dp"
    android:maxHeight="225dp"
    android:padding="0dp"/>
</RelativeLayout>
InformationsquelleAutor Neanderthal | 2015-11-09
Schreibe einen Kommentar