title: Recyclerview not scrolling inside Nested ScrollView
body: <p>I have <code>Recyclerview</code> which is under <code>Coordinatorlayout</code> > <code>NestedScrollview</code> > <code>ViewPager</code> and <code>ViewPager</code> has 3 fragment, one has image gallery which is working with the help of <code>Recyclerview</code>. Whenever i tried to scroll up or down it doesn't scroll at all. I have already set <code>photosRecycler.setNestedScrollingEnabled(false);</code> and as soon as i remove this line i am getting scroll working only down side and when i tried to move back up it move up with parent <code>Nestedscrollview</code>. </p>
  
  <p>My layout manager is also showing StaggeredGrid as Grid i need to get this kind of layout</p>
  
  <p><a href="https://i.stack.imgur.com/EiPYH.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/EiPYH.jpg" alt="enter image description here"></a></p>
  
  <p>Here is my parent layout for Nestedscrollview</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:background="?android:attr/colorBackground"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;com.google.android.material.appbar.AppBarLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
          &lt;com.google.android.material.appbar.CollapsingToolbarLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:fitsSystemWindows="true"
              app:expandedTitleMarginStart="48dp"
              app:expandedTitleMarginEnd="64dp"
              app:contentScrim="?attr/colorPrimary"
              app:layout_scrollFlags="scroll|enterAlways"&gt;
  
              &lt;androidx.constraintlayout.widget.ConstraintLayout
  
  
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:background="?android:colorBackground"&gt;
  
  
                  &lt;ImageView
  
                      android:layout_width="match_parent"
                      android:layout_height="500dp"
                      android:src="@color/custom_transparent_colorBlack"
                      android:scaleType="centerCrop"
                      app:layout_constraintEnd_toEndOf="parent"
                      app:layout_constraintHorizontal_bias="0.0"
                      app:layout_constraintStart_toStartOf="parent"
                      app:layout_constraintTop_toTopOf="parent"
                      /&gt;
  
                  &lt;de.hdodenhof.circleimageview.CircleImageView
  
                      android:layout_width="128dp"
                      android:layout_height="128dp"
                      app:layout_constraintBottom_toBottomOf="@+id/coverPhoto"
                      app:layout_constraintEnd_toEndOf="parent"
                      app:layout_constraintStart_toStartOf="parent"
                      app:layout_constraintTop_toTopOf="@+id/coverPhoto"
                      app:layout_constraintVertical_bias="0.44"
                      tools:srcCompat="@tools:sample/avatars" /&gt;
  
  
  
              &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
          &lt;/com.google.android.material.appbar.CollapsingToolbarLayout&gt;
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
      &lt;androidx.core.widget.NestedScrollView
          android:id="@+id/up_NestedScrollView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:overScrollMode="never"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"
  
          &gt;
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:paddingLeft="5dp"
              android:paddingRight="5dp"
              &gt;
              &lt;com.google.android.material.tabs.TabLayout
                  android:id="@+id/tabItemes"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  app:tabGravity="fill"
                  app:tabPaddingBottom="0dp"
                  app:tabPaddingEnd="0dp"
                  app:tabPaddingStart="0dp"
                  app:tabPaddingTop="0dp"
                  app:tabIndicatorHeight="0dp"
                  app:tabMode="fixed"
                  app:tabTextColor="@color/black"
                  app:tabSelectedTextColor="@color/primary"
                  app:tabIndicatorColor="@color/primary_light"&gt;
  
                  &lt;com.google.android.material.tabs.TabItem
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="About" /&gt;
  
                  &lt;com.google.android.material.tabs.TabItem
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Media" /&gt;
  
                  &lt;com.google.android.material.tabs.TabItem
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Con" /&gt;
              &lt;/com.google.android.material.tabs.TabLayout&gt;
  
              &lt;androidx.viewpager.widget.ViewPager
  
                  android:layout_below="@id/tabItemes"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/androidx.core.widget.NestedScrollView&gt;
  &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>Image Gallery Fragment</p>
  
  <pre><code>public class UserPhoto_fragment extends Fragment {
      public static final String TAG="### USER PHOTO ####";
      RecyclerView photosRecycler;
      fetchPhoto_Adapter adapter;
      StaggeredGridLayoutManager layoutManager;
      ArrayList&lt;String&gt; ImageList;
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
          View view=inflater.inflate(R.layout.userprofile_photos,container,false);
          setRetainInstance(true);
          photosRecycler=view.findViewById(R.id.userPhotos_recycler);
          layoutManager= new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);
          layoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
          ImageList=new ArrayList&lt;&gt;();
          SpacesItemDecoration itemDecoration = new SpacesItemDecoration(16);
          photosRecycler.addItemDecoration(itemDecoration);
          photosRecycler.setLayoutManager(layoutManager);
          photosRecycler.setHasFixedSize(true);
          photosRecycler.setNestedScrollingEnabled(false);
  
          return view;
      }
  
      @Override
      public void onResume() {
          super.onResume();
          Log.d(TAG, "onResume: User Photo Fragment "+getView()+ ImageList.size() );
          if (ImageList.size()==0){
              new fetch_photo().execute();
          }
      }
  
      public class fetchPhoto_Adapter extends RecyclerView.Adapter&lt;fetchPhoto_Adapter.ViewHolder&gt;{
  
          @NonNull
          @Override
          public fetchPhoto_Adapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
              LayoutInflater inflater= (LayoutInflater) viewGroup.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              View v = inflater.inflate(R.layout.userprofile_photogallery,viewGroup,false);
              return new ViewHolder(v);
          }
  
          @Override
          public void onBindViewHolder(fetchPhoto_Adapter.ViewHolder viewHolder, int i) {
              Glide.with(getActivity()).load(ImageList.get(i)).apply(new RequestOptions().centerCrop()).into(viewHolder.image);
          }
  
          @Override
          public int getItemCount() {
              if (ImageList!=null &amp;&amp; ImageList.size()&gt;0){
                  return ImageList.size();
              }else {
                  return 0;
              }
          }
  
          public class ViewHolder extends RecyclerView.ViewHolder {
              ImageView image;
              public ViewHolder(View itemView) {
                  super(itemView);
                  image = itemView.findViewById(R.id.UserProfile_photoThumb);
              }
          }
  
      }
  
  }
  </code></pre>
  
  <p>Layout file for image gallery</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_marginTop="20dp"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;androidx.recyclerview.widget.RecyclerView
          android:id="@+id/userPhotos_recycler"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"
          android:scrollbars="vertical"&gt;
  
      &lt;/androidx.recyclerview.widget.RecyclerView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I am facing 2 issue with this code </p>
  
  <ol>
  <li>Recyclerview not working in nestedscrollview.</li>
  <li>StaggeredGridLayoutManager is showing images like GridLayoutManager</li>
  </ol>
  
  <p>Please help me to resolve these issue.Thanks</p>