2016-01-15 9 views
7

In meiner Tätigkeit habe ich zwei RecyclerView s in einem ScrollView. Das Problem ist, dass, wenn ich das ScrollView swipe/flick, das Scrollen sofort stoppt. Gibt es eine Möglichkeit, den ScrollView Impuls oder Trägheit zu implementieren, so gibt es etwas Verzögerung, bevor das Scrollen aufhört?Keine Freigabe Moment in ScrollView

Meine XML ist unter:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<ProgressBar 
    android:id="@+id/threadload_progress" 
    style="?android:attr/progressBarStyleLarge" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="8dp" 
    android:visibility="gone" /> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/subforums" 
     android:name="net.polunom.forum.fragments.ThreadFragment" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layoutManager="LinearLayoutManager" 
     tools:context=".fragments.ThreadFragment" 
     tools:listitem="@layout/fragment_subforum"/> 

    <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/threadlist" 
     android:name="net.polunom.forum.fragments.ThreadFragment" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layoutManager="LinearLayoutManager" 
     tools:context=".fragments.ThreadFragment" 
     tools:listitem="@layout/fragment_thread"/> 

</LinearLayout> 
</ScrollView> 

Antwort

13

ich es herausgefunden! Alles, was ich tun musste, war setNestedScrollingEnabled(false); zu den beiden RecyclerView s, und alles begann wie ein Charme zu arbeiten.

+0

Das ist für mich gearbeitet. Ich habe meine RecyclerView in einem CollapsingToolbarLayout, und das hat funktioniert. –

1

Sie können deaktivieren verschachtelt mit direkt in die XML-Scrolling: android:nestedScrollingEnabled="false"

So Ihre XML würde wie folgt aussehen:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<ProgressBar 
    android:id="@+id/threadload_progress" 
    style="?android:attr/progressBarStyleLarge" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="8dp" 
    android:visibility="gone" /> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/subforums" 
     android:nestedScrollingEnabled="false" 
     android:name="net.polunom.forum.fragments.ThreadFragment" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layoutManager="LinearLayoutManager" 
     tools:context=".fragments.ThreadFragment" 
     tools:listitem="@layout/fragment_subforum"/> 

    <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/threadlist" 
     android:nestedScrollingEnabled="false" 
     android:name="net.polunom.forum.fragments.ThreadFragment" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layoutManager="LinearLayoutManager" 
     tools:context=".fragments.ThreadFragment" 
     tools:listitem="@layout/fragment_thread"/> 

</LinearLayout> 
</ScrollView>