4

J'ai un RecycleView qui a une liste de CardsViews. Le RecycleView est dans un NestedScrollView, parce que j'ai un en-tête réductible. Le défilement n'est pas accéléré, il arrête de défiler quand je prends le doigt de l'écran, et je veux un défilement accéléré.Accéléré Défilement sur la vue de recyclage

Voici mes mises en page.

<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> 

Mon conteneur de disposition CardView.

<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> 

Et le code JAVA:

 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); 

Merci.

EDIT:

Ma nouvelle mise en page fonctionne et ressemble à:

<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

J'ai exactement le même problème, Toute solution? – AVEbrahimi

Répondre

0

travaille changer la mise en page:

<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

C'est parce que vous définissez votre RecyclerView dans le ScrollView. Donc Pour activer rapidement son défilement ajouter cette ligne dans votre fichier xml dans RecyclerView Tag

android:nestedScrollingEnabled="false" 

ou de le faire ajouter dynamiquement cette ligne dans votre fichier Java

recyclerView.setNestedScrollingEnabled(false);