Android RecyclerView在填充父容器后滚动
我有一个包含wrap_内容的RecyclerView,当RecyclerView包含一些项目时,高度可以正常工作,但是当RecyclerView填充父项时,RecyclerView开始滚动 这是布局图:Android RecyclerView在填充父容器后滚动,android,android-recyclerview,Android,Android Recyclerview,我有一个包含wrap_内容的RecyclerView,当RecyclerView包含一些项目时,高度可以正常工作,但是当RecyclerView填充父项时,RecyclerView开始滚动 这是布局图: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientati
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/white"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".activity.RegistroVentaActivity$BusquedaFragment">
<RelativeLayout
android:id="@+id/rlManualSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- some items kind of header -->
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlResults"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/palette_flat_asphalt_3"
android:visibility="visible">
<TextView
android:id="@+id/tvResultsHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/palette_flat_asphalt_3"
android:padding="10dp"
android:text="@string/search_results_hint"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/white" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rvProductosCoinsidencias"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvResultsHint"
android:background="@android:color/white"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:clipToPadding="false"
android:columnWidth="@dimen/rv_productos_column_width"
android:padding="@dimen/rv_item_padding"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
注意:布局是一个片段(ViewPager),父级是一个
协调布局
所以“标题”总是在屏幕上,RecyclerView开始滚动
当recyclerView达到父级高度时,我需要将所有内容一起滚动
我该怎么做呢
我正在使用
- 支持:设计:24.0.0
- support:support-v4:24.0.0
- nestedScrollEnabled true,false
- hasFixedSize为真,为假
- 可自动测量的真、假
- 直线布局经理
- 网格布局管理器
- CustomsLayoutManager(来自谷歌搜索)
- 旧的官方版本
似乎什么都不起作用。这是RecyclerView的默认行为。有两种方法可以实现您的目标:
这是RecyclerView的默认行为。有两种方法可以实现您的目标:
我可以按照我的要求将内容滚动到一起,但滚动不会折叠CollazingToolbarLayout,我需要在ScrollView中配置什么才能调用CollazingToolbarLayout的折叠效果?NestedScrollView(而不是ScrollView)完成了折叠CollazingToolbarLayout的工作,非常感谢:Di可以按照我的要求将内容滚动到一起,但是滚动不会折叠CollingToolbarLayout,我需要在ScrollView中配置什么才能调用CollingToolbarLayout的折叠效果?NestedScrollView(而不是ScrollView)完成了折叠ToolbarLayout的工作,非常感谢:D