Reputation: 2533
So I have an Activity which uses a NestedScrollView and inside that NestedScrollView is a ViewPager. That ViewPAger contains 2 fragments. One has layouts inside scrollview and another one has recyclerView.
But both fragments are not scrolling (neither scrollview nor recyclerview).
Activity XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/ll_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/colorPrimary"
android:orientation="vertical">
// Some Textview & imagehview here
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/ll_header"
android:orientation="vertical">
<com.ogaclejapan.smarttablayout.SmartTabLayout
android:id="@+id/movietab"
android:layout_width="match_parent"
android:layout_height="@dimen/_40sdp"
android:background="@color/colorAccent"
android:paddingBottom="@dimen/_2sdp"
app:stl_defaultTabTextColor="@color/white"
app:stl_defaultTabTextHorizontalPadding="@dimen/_20sdp"
app:stl_distributeEvenly="true"
app:stl_indicatorColor="@color/white"
app:stl_indicatorCornerRadius="1dp"
app:stl_indicatorInterpolation="smart"
app:stl_indicatorThickness="3dp"
app:stl_underlineColor="@color/transparent" />
<android.support.v4.view.ViewPager
android:id="@+id/mViewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/movietab" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Fragment1 XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color1">
<ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fillViewport="true">
<LinearLayout
android:id="@+id/llInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
//Inner Layout
</LinearLayout>
</ScrollView>
</RelativeLayout>
Fragment2 XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/llCasting"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.movies.MovieCastFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvCast"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
I tried android:nestedScrollingEnabled=""
true and false on each and every layout but never got desired result.
Fragment's ScrollView and RecyclerView are scolling but I don't want to scroll them, I want to scroll Activity's Nested ScrollVIew.
Upvotes: 2
Views: 811
Reputation: 1337
The height of your ViewPager should be set to wrap_content and nested scrolling should be set to false so that the parent NestedScrollView will be put in charge of the scrolling.
Upvotes: 0