简体   繁体   English

RecyclerView不会在折叠工具栏中滚动

[英]RecyclerView not scrolling in Collapsing Toolbar

I have a very simple RecyclerView inside a Collapsing Toolbar layout. 我在Collapsing Toolbar布局中有一个非常简单的RecyclerView。 I have tried every possible flag / researched everywhere I could but cannot get my collapsing toolbar to collapse. 我已尽力尝试每一个可能的旗帜/研究,但无法使我的折叠工具栏崩溃。 The Recycler scrolls freely, but the collapsingtoolbar just stays there, unless, I scroll the collapsingtoolbar itself. Recycler可以自由滚动,但是折叠工具栏只是停留在那里,除非我滚动折叠工具栏本身。 What am I doing wrong, can anyone please help? 我做错了什么,有人可以帮忙吗? Any help will be much much appreciated.. 任何帮助将非常感谢..

XML as follows (Just to keep the code clean, have removed the section within the Relative Layout of the Collapsing toolbar): XML如下(只是为了保持代码干净,删除了折叠工具栏的相对布局中的部分):

<!-- The CoordinatorLayout is used to coordinate (rly) scroll events between different views -->
<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<!-- The AppBar (everything above the scrolling content) -->
<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:id="@+id/activity_main__app_bar"
    android:fitsSystemWindows="true"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">



<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/activity_main__collapsing_toolbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minHeight="0dp"
    android:fitsSystemWindows="true"
    app:contentScrim="@color/dark_for_menu"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:layout_collapseMode="parallax" >

    <RelativeLayout
        android:id="@+id/coverSwappsterMode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

    </RelativeLayout>


<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:layout_collapseMode="pin" >


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

</android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>




            <android.support.v7.widget.RecyclerView
                android:id="@+id/listSwappsterMode"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:minHeight="@dimen/dp_500"
                android:background="@color/dark_background"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                >
            </android.support.v7.widget.RecyclerView>





</android.support.design.widget.CoordinatorLayout>

you need to put your page layout inside a "nested scroll view" 您需要将页面布局放在“嵌套滚动视图”中

<android.support.v4.widget.NestedScrollView>

wrapping the recyclerview should do it. 包装recyclerview应该这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM