Android 如何使页面查看器和网格视图一起滚动?

Android 如何使页面查看器和网格视图一起滚动?,android,android-layout,scrollview,Android,Android Layout,Scrollview,我的布局中有ViewPager和grid视图。目前只有grid视图在page ViewPager下方滚动。如何使这两个视图都可以垂直滚动?我使用了嵌套滚动,但没有任何效果..请指导我 布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" xmlns:tools="http:

我的布局中有ViewPager和grid视图。目前只有grid视图在page ViewPager下方滚动。如何使这两个视图都可以垂直滚动?我使用了嵌套滚动,但没有任何效果..请指导我

布局:

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context=".MainActivity"
xmlns:android="http://schemas.android.com/apk/res/android">
 <androidx.viewpager.widget.ViewPager
    android:layout_width="match_parent"
    android:layout_height="140dp"
    android:id="@+id/viewpagermain"
    android:layout_gravity="center_horizontal">

  </androidx.viewpager.widget.ViewPager>
<View
  android:layout_width="match_parent"
  android:layout_height="2dp"
  android:background="#c0c0c0"/>
 <GridView
  android:id="@+id/mGridView"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingTop="5dp"
  android:paddingLeft="5dp"
  android:paddingRight="5dp"
  android:numColumns="auto_fit"
  android:columnWidth="172dp"
  android:horizontalSpacing="5dp"
  android:verticalSpacing="5dp"
  android:gravity="center"
  android:stretchMode="columnWidth"
  android:background="#ffffff">
</GridView>
</LinearLayout>


NestedScrollView顾名思义,当需要在另一个滚动视图中使用滚动视图时使用。请尝试使用带有选项ViewCompat.setNestedScrollingEnabled(可滚动,false)的android.support.v4.widget.NestedScrollView;