SwipeRefreshLayout beeinträchtigt ScrollView in einem ViewPager
Ich habe ein SwipeRefreshLayout um einen ViewPager. Die vom ViewPager geladenen Fragmente enthalten ScrollViews. Wenn ich nach unten scrolle, funktioniert es einwandfrei, aber wenn ich nach oben scrolle, wird das SwipeRefreshLayout aktiviert, ohne dass die ScrollView zuerst nach oben scrollen muss. Wie kann ich sicherstellen, dass die ScrollView Priorität hat?
Es hat gut funktioniert, wenn sich das SwipeRefreshLayout in den einzelnen Fragmenten direkt außerhalb der ScrollView befand, aber ich brauche es für die Aktivität selbst um den ViewPager.
Hier sind die relevanten Layouts:
Aktivität
<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="#EEEEEE"
android:fitsSystemWindows="true">
<include layout="@layout/toolbar" />
<io.karim.MaterialTabs
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/primary"
app:mtIndicatorColor="@color/icons"
app:mtIndicatorHeight="2dp"
app:mtSameWeightTabs="true"
app:mtPaddingMiddle="false"
app:mtTextColorSelected="@color/icons"
android:textColor="@color/icons"
android:elevation="4dp"
tools:ignore="UnusedAttribute" />
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeRefresh"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
Vom ViewPager geladenes Fragment (es gibt 5 Registerkarten mit jeweils einer davon):
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="me.sargunvohra.android.purduediningcourts.presenter.MenuFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin"
android:paddingEnd="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
>
<!-- Content snipped for brevity -->
<!-- blah blah... lots of content here -->
</LinearLayout>
</ScrollView>
Und hier ist das Repo auf GitHub, falls Sie weitere Informationen benötigen:https: //github.com/sargunster/purdue-dining-courts-androi