NestedScrolling avec NestedScrollView, RecyclerView (Horizontal), dans un CoordinatorLayout
J'ai une conception de l'INTERFACE utilisateur avec CollapsingToolbarLayout, comme suit.
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/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="wrap_content"
android:fillViewport="true"
android:theme="@style/ThemeOverlay.AppCompat.Light"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="24dp">
<!-- Hiding unrelated code -->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_margin"
android:padding="16dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_movie_suggestion"
android:layout_width="match_parent"
android:layout_height="170dp"
android:fillViewport="true"
android:nestedScrollingEnabled="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Mon problème est, le défilement est très bien SEULEMENT quand je touche de défilement et de la zone à l'EXTÉRIEUR de la RecyclerView. Si j'essaie de faire défiler verticalement à l'intérieur de la RecyclerView, le défilement est "pris au piège" et SEUL le NestedScrollView est le défilement, le CollaspingToolbarLayout N'est PAS collasping.
source d'informationauteur Fung LAM
Vous devez vous connecter pour publier un commentaire.
Vous avez besoin de désactiver imbriquée défilement par programmation. Il ne semble pas fonctionner correctement si elle est faite en xml.
Ce est la question la plus courante lors de l'utilisation recyclerview à l'intérieur de nestedscrollview.
J'ai corrigé cela en ajoutant des lignes suivantes dans le xml.
Hey, si vous êtes intéressé, j'ai créé un LayoutManager qui devrait résoudre votre problème.
https://github.com/emanuelet/LayoutManagers/blob/master/ExpansiveLayoutManager.java
Vous n'avez pas besoin de mettre votre recyclerView à l'intérieur de NestedScrollView.
Vous n'avez pas à utiliser NestedScrollView. Il suffit de laisser LinearLayout.