4

Ich habe eine RecycleView, die eine Liste von CardsViews haben. Die RecycleView befindet sich in einer NestedScrollView, weil ich eine reduzierbare Kopfzeile habe. Der Bildlauf wird nicht beschleunigt, es hört auf zu scrollen, wenn ich den Finger vom Bildschirm nehme, und ich möchte beschleunigt scrollen.Beschleunigte Scroll auf Recycle View

Das sind meine Layouts.

<android.support.v4.widget.NestedScrollView 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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".articles.ArticlesActivity" 
    tools:showIn="@layout/activity_articles" 
    > 


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/articles_lista" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fadeScrollbars="true" 
     android:scrollbars="vertical" 
     /> 

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

Mein CardView-Layout-Container.

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/articles_card" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    card_view:cardCornerRadius="6dp" 
    card_view:cardUseCompatPadding="true" 
    card_view:cardPreventCornerOverlap="true" 
    android:layout_marginTop="0dp" 
    android:layout_marginBottom="0dp" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    card_view:cardElevation="5dp" 

    android:overScrollMode="always" 
    android:fadeScrollbars="true"> 

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

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="10dp" 
      android:id="@+id/article_card_title" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="#000"/> 

    </LinearLayout> 

</android.support.v7.widget.CardView> 

Und der JAVA-Code:

 RecyclerView recyclerView = (RecyclerView)findViewById(R.id.articles_lista); 
     LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); 
     recyclerView.setLayoutManager(layoutManager); 
     ArticlesAdapter adapter = new ArticlesAdapter(Mock.getNoticias(1L), this); 
     recyclerView.setAdapter(adapter); 

Dank.

EDIT:

Mein neues Layout funktioniert und wie folgt aussieht:

<RelativeLayout 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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="newser.sab.com.newser.articles.ArticlesActivity2" 
    tools:showIn="@layout/app_bar_articles2"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/articles_lista" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fadeScrollbars="true" 
     android:scrollbars="vertical" 
     /> 

</RelativeLayout> 
+0

Ich habe genau gleiches Problem zu tun, irgendeine Lösungsmöglichkeit? – AVEbrahimi

Antwort

0

arbeitet das Layout zu ändern:

<RelativeLayout 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:layout_width="match_parent" 
android:layout_height="match_parent" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="newser.sab.com.newser.articles.ArticlesActivity2" 
tools:showIn="@layout/app_bar_articles2"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/articles_lista" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fadeScrollbars="true" 
    android:scrollbars="vertical" 
    /> 

0

Das ist, weil Sie setzen Ihre RecyclerView innerhalb der ScrollView. So Um seine Scrollen schneller fügen Sie diese Zeile in Ihrer xml Datei in RecyclerView Tag

android:nestedScrollingEnabled="false" 

zu aktivieren oder es dynamisch fügen Sie diese Zeile in Ihrer Java-Datei

recyclerView.setNestedScrollingEnabled(false);