如何使包含嵌入式 RecyclerView 的 Android 视图作为一个整体滚动?

How to make an Android view containing an embedded RecyclerView to scroll as a single piece?

我有这个版面还是Android有问题:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="1"
          android:orientation="vertical">

<ImageView
    android:id="@+id/influencerMainPhotoImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"/>

<android.support.v7.widget.RecyclerView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/photos_list"
    android:name="com.company.android.InfluencerFragment"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_weight="1"
    app:layoutManager="LinearLayoutManager"
    tools:context="com.company.android.InfluencerFragment"
    tools:listitem="@layout/fragment_photo"/>
</LinearLayout>

问题是嵌入式 RecyclerView 正在进行嵌套滚动(即它在自身内部滚动)- 我不想要这个。

我想将整个屏幕作为一个整体滚动。

我试图设置 "view.setNestedScrollingEnabled(false);"(在 LinearLayout 视图上),但它说它仅适用于 API 21 及更高版本。我的项目设置为 min API 15.

怎样才能让整个屏幕滚动成一个整体?

您可以将 View 替换为 ViewCompat(v4 兼容库):

https://developer.android.com/reference/android/support/v4/view/ViewCompat.html

你有 setNestedScrollingEnabled(boolean); 方法。