2
votes

Comment résoudre le problème de défilement de la barre d'outils de réduction

J'essaie d'implémenter la barre d'outils de réduction que j'implémente mais je n'obtiens pas un résultat correct.

Quand j'essaierai de faire défiler en utilisant l'élément recyclerview, il ne défile pas correctement, mais d'une manière ou d'une autre, il défile bien si je défile au toucher en dehors de recyclerview

Je reçois ce résultat

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/ctolbar"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/colorPrimary"
            app:collapsedTitleTextAppearance="@style/collapsed"
            app:expandedTitleMargin="5dp"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleTextAppearance="@style/CollapsingToolbarLayoutExpandedTextStyle"
            app:layout_scrollFlags="enterAlways|enterAlwaysCollapsed|scroll"
            app:title="Profile">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/cover"
                android:orientation="vertical">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/gradient_cover" />
            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:scrollbars="none"
        app:behavior_overlapTop="100dp"
        app:layout_anchor="@id/appbar"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <FrameLayout
                android:id="@+id/flmiddle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingLeft="30dp"
                android:paddingRight="30dp">

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="35dp"
                    android:background="@drawable/background_round">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="40dp"
                        android:gravity="center_horizontal"
                        android:orientation="vertical"
                        android:paddingLeft="16dp"
                        android:paddingRight="16dp">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="16dp"
                            android:layout_marginBottom="5dp"
                            android:fontFamily="@font/righteous_regular"
                            android:gravity="center"
                            android:text="Jack Sparrow"
                            android:textColor="#ff3f4751"
                            android:textSize="25sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/tvaddress"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="5dp"
                            android:layout_marginBottom="16dp"
                            android:gravity="center"
                            android:fontFamily="@font/roboto_regular"
                            android:text="221 B Baker Street, London"
                            android:textSize="15sp" />

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="16dp"
                            android:layout_marginBottom="16dp"
                            android:orientation="horizontal"
                            android:weightSum="3">

                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:gravity="center_horizontal"
                                android:orientation="vertical">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="Purchased"
                                    android:fontFamily="@font/josefinsans_semibold"
                                    android:textAllCaps="true"
                                    android:textColor="#ff878b91"
                                    android:textSize="10sp" />

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:fontFamily="sans-serif-condensed"
                                    android:text="1.5 K"
                                    android:textColor="#ff3f4751"
                                    android:textSize="24sp"
                                    android:textStyle="normal" />
                            </LinearLayout>

                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:gravity="center_horizontal"
                                android:orientation="vertical">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="Wished"
                                    android:textAllCaps="true"
                                    android:fontFamily="@font/josefinsans_semibold"
                                    android:textColor="#ff878b91"
                                    android:textSize="10sp" />

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:fontFamily="sans-serif-condensed"
                                    android:text="1.1 K"
                                    android:textColor="#ff3f4751"
                                    android:textSize="24sp" />
                            </LinearLayout>

                            <LinearLayout
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_weight="1"
                                android:gravity="center_horizontal"
                                android:orientation="vertical">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="Likes"
                                    android:textAllCaps="true"
                                    android:fontFamily="@font/josefinsans_semibold"
                                    android:textColor="#ff878b91"
                                    android:textSize="10sp" />

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:fontFamily="sans-serif-condensed"
                                    android:text="450"
                                    android:textColor="#ff3f4751"
                                    android:textSize="24sp" />
                            </LinearLayout>
                        </LinearLayout>
                    </LinearLayout>
                </FrameLayout>

                <ImageView
                    android:id="@+id/imgprofile"
                    android:layout_width="68dp"
                    android:layout_height="68dp"
                    android:layout_gravity="center|top" />
            </FrameLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginTop="20dp"
                android:layout_marginRight="16dp"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:fontFamily="@font/righteous_regular"
                    android:text="Collection"
                    android:textColor="#ff3f4751"
                    android:textSize="20sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:fontFamily="sans-serif"
                    android:text="More"
                    android:textColor="#ff3f4751"
                    android:textSize="15sp" />
            </LinearLayout>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/RecyclerViewCollection"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:clipToPadding="false"
                android:orientation="horizontal"
                android:paddingLeft="16dp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginTop="30dp"
                android:layout_marginRight="16dp"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:fontFamily="@font/righteous_regular"
                    android:text="Tags"
                    android:textColor="#ff3f4751"
                    android:textSize="20sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:fontFamily="sans-serif"
                    android:text="More"
                    android:textColor="#ff3f4751"
                    android:textSize="15sp" />
            </LinearLayout>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/RecyclerViewTags"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:clipToPadding="false"
                android:paddingLeft="16dp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginTop="30dp"
                android:layout_marginRight="16dp"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:fontFamily="@font/righteous_regular"
                    android:text="Offers!!!"
                    android:textColor="#ff3f4751"
                    android:textSize="20sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:fontFamily="sans-serif"
                    android:text="More"
                    android:textColor="#ff3f4751"
                    android:textSize="15sp" />
            </LinearLayout>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/RecyclerViewOffers"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp"
                android:clipToPadding="false"
                android:orientation="horizontal"
                android:paddingLeft="16dp" />
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

Toute aide serait très appréciée


0 commentaires

3 Réponses :


2
votes

Essayez de mettre ceci:

app:layout_behavior="@string/appbar_scrolling_view_behavior"

dans les propriétés de RecyclerView.


0 commentaires

3
votes

Vous pouvez désactiver le défilement imbriqué pour RecyclerView tout en l'utilisant avec NestedScrollView

ViewCompat.setNestedScrollingEnabled(this, shouldScroll)

ou pour prendre en charge les anciennes versions;

recyclerView.isNestedScrollingEnabled = false


1 commentaires

android: nestedScrollingEnabled = "false" fonctionne pour moi



1
votes

Vous devriez essayer pour CollapsingToolbarLayout

app:layout_scrollFlags="scroll|exitUntilCollapsed"

et pour Toolbar

app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"

Essayez également de suivre this strong > , cela vous aidera sûrement beaucoup.


0 commentaires