0

Ich habe eine Listenansicht mit horizontalem Bildlauf mithilfe von RecyclerView in Bildlaufansicht implementiert. Ich möchte das Element aktualisieren, wenn der Benutzer zum Ende der Listenansicht wischt (das Element wird nach der Aktualisierung hinzugefügt). Der folgende Code ist die Layout-Implementierung.RecyclerView innerhalb von SwipeRefreshLayout wird nicht angezeigt

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <android.support.v4.widget.SwipeRefreshLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       app:layoutManager="android.support.v7.widget.LinearLayoutManager"> 

      </android.support.v7.widget.RecyclerView> 
     </android.support.v4.widget.SwipeRefreshLayout> 

    </LinearLayout> 

</ScrollView> 

Bevor ich SwipeRefreshLayout hinzufügen, funktioniert alles einwandfrei (Artikel in RecyclerView gezeigt normal), aber nachdem ich SwipeRefreshLayout hinzufügen, wird RecyclerView gegangen (sowohl im Gerät und in der Vorschau in Android Studio)

Könnten Sie Abbildung heraus, wie man dieses Problem beheben kann. Danke im Voraus!!

EDIT Hier sind, was ich Scroll itself
Refresy RecyclerView

+1

SwipeRefreshLayout Mutter hinzufügen und Scroll-Ansicht – Pavya

Antwort

2

Versuchen Sie dies tun wollen,

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin"> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       app:layoutManager="android.support.v7.widget.LinearLayoutManager" /> 

      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       app:layoutManager="android.support.v7.widget.LinearLayoutManager" /> 

     </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 

</android.support.v4.widget.SwipeRefreshLayout> 
+0

Ein Haupt Layout entfernen sollte scrollbaren werden. Tatsächlich gibt es viele Elemente in ScrollView. –

+0

Lassen swiperefresh Layout Eltern sein und fügen Sie eine verschachtelte scrollview in diesem linearen Layout und legen Sie Ihre Artikel dort. – kcg

+0

Gibt es mehr als ein RecyclerView mit SwipeRefresh auf der gleichen Seite? Vielleicht muss ich einen Screenshot hinzufügen, um das Problem zu verdeutlichen. –

Verwandte Themen