Android 如何在ScrollView中嵌套两个RecyclerView并禁用ScrollView';卷轴

Android 如何在ScrollView中嵌套两个RecyclerView并禁用ScrollView';卷轴,android,android-recyclerview,scrollview,Android,Android Recyclerview,Scrollview,我有一个这样的活动: <?xml version="1.0" encoding="utf-8"?> <com.hyqfx.recyclerviewtest.LockScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <

我有一个这样的活动:

<?xml version="1.0" encoding="utf-8"?>
<com.hyqfx.recyclerviewtest.LockScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

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

    <android.support.v7.widget.RecyclerView
      android:id="@+id/recycler_view_1"
      android:layout_width="match_parent"
      android:layout_height="400dp"/>

    <android.support.v7.widget.RecyclerView
      android:id="@+id/recycler_view_2"
      android:layout_width="match_parent"
      android:layout_height="400dp"/>
  </LinearLayout>

</com.hyqfx.recyclerviewtest.LockScrollView>
public class LockScrollView extends ScrollView {
  public LockScrollView(Context context) {
    super(context);
  }

  public LockScrollView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public LockScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
  }

  @Override public boolean onTouchEvent(MotionEvent ev) {
    return false;
  }
}
在这种情况下,scrollview不会首先滚动,但当recyclerview滚动到底部时,父scrollview会再次工作

但是我希望scrollview永远不能工作


有人能帮我吗?非常感谢

使用
NestedScrollView
而不是
ScrollView

您可以使用以下方法之一: 将此行添加到
recyclerView
xml视图:

android:nestedScrollingEnabled=“false”

试试看,
recyclerview
将以灵活的高度平滑滚动


希望这有帮助。

相反,禁用scrollview的滚动删除该滚动视图并进行线性布局android:layout\u height as match\u Parents如果这样做,第二个recyclerview将被剪切,我需要它保持400dp的高度。你试过NestedScrollView吗?而不是LockScrollView尝试NestedScrollView并检查它是否具有相同的结果。您可以通过尝试的方式发布NestedScrollView代码部分吗?我想知道你是如何使用的。它使回收视图没有滚动。