0
votes

Problème de défilement dans RecyclERView. Le défilement n'est pas lisse

Ceci est mon code-

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".MainActivity">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <TextView
        android:id="@+id/frame1"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:text="Recruitment Responses"
        android:gravity="center"
        android:textSize="30sp"
        android:textColor="#fff"
        android:background="@drawable/bg_rounded1"
        />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:padding="16dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/frame1"
        android:background="#f9fafc"/>
    </RelativeLayout>
</ScrollView>
</RelativeLayout>


2 commentaires

Les vues de nidification qui font défiler dans la même direction (horizontale / verticale) ne sont généralement pas une bonne idée.


Essayez d'utiliser CoordinatorLayout, CollapsibletoolBar pour atteindre le comportement. Utilisation d'un RECYCLERView avec une hauteur définie sur wrap_content n'est pas une bonne idée si vous avez un grand ensemble d'articles.


3 Réponses :


0
votes

Essayez ceci:

recyclerView.setScrollView(true);


2 commentaires

Voici le Documentation à Androidx.RecyClerview.Widget. Recyclerview . Trouvez-vous des SetscrollView () Méthode là-bas?


@Wrichik bassu c'est secret



1
votes

Ajout d'un Au lieu de ScrollView résout tout.

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".MainActivity">

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <TextView
        android:id="@+id/frame1"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:text="Recruitment Responses"
        android:gravity="center"
        android:textSize="30sp"
        android:textColor="#fff"
        android:background="@drawable/bg_rounded1"
        />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:padding="16dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/frame1"
        android:background="#f9fafc"/>
    </RelativeLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>


0 commentaires

0
votes

Essayez-le dans votre activité:

recyclerView.setNestedScrollingEnabled(false);


0 commentaires