RecyclerView Not Scrolling inside Sub ViewPager
Asked Answered
D

0

6

Well After Spending hours together on the issue I finally thought to post here for the Solution... App Hierarchy is as Follows:

  • tab1/tab2/tab3/tab4 (Tab Views with ViewPagers)
  • tab1 has Another tab layout with View Pagers
  • tab1--> subtab1,subtab2,subtab3(Tab Views with ViewPagers)

Im able to Scroll Tab1, but Unable to scroll RecyclerView inside subtab1(which is a child of Tab1).

Here is Xml for Main Tab Layout:

<LinearLayout 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:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

Here is xml for tab1:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <com.daimajia.slider.library.SliderLayout
                    android:id="@+id/homeBannerSlider"
                    android:layout_width="match_parent"
                    android:layout_height="150dp"
                    app:indicator_visibility="visible"
                    app:pager_animation="Default"
                    app:pager_animation_span="400">

                    <com.daimajia.slider.library.Indicators.PagerIndicator
                        android:id="@+id/custom_indicator"
                        style="@style/AndroidImageSlider_Corner_Oval_Orange"
                        android:layout_alignParentBottom="true"
                        android:layout_centerHorizontal="true"
                        android:background="#00000000" />
                </com.daimajia.slider.library.SliderLayout>
            </RelativeLayout>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginBottom="10dp"
                android:elevation="0dp"
                app:cardCornerRadius="0dp"
                app:cardElevation="0dp">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <ImageView
                        android:id="@+id/speaker_image"
                        android:layout_width="20dp"
                        android:layout_height="20dp"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:background="#F7CA18" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_toRightOf="@+id/speaker_image"
                        android:text=" Dynamic Message........" />
                </RelativeLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:elevation="0dp"
                app:cardCornerRadius="0dp"
                app:cardElevation="0dp">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="20dp"
                        android:text="Latest Results" />
                </RelativeLayout>
            </android.support.v7.widget.CardView>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:orientation="horizontal">

                <android.support.v7.widget.CardView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:elevation="0dp"
                    app:cardCornerRadius="0dp"
                    app:cardElevation="0dp">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#858585"></RelativeLayout>
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:elevation="0dp"
                    app:cardCornerRadius="0dp"
                    app:cardElevation="0dp">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#757575"></RelativeLayout>
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:elevation="0dp"
                    app:cardCornerRadius="0dp"
                    app:cardElevation="0dp">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#858585"></RelativeLayout>
                </android.support.v7.widget.CardView>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="vertical">
                <android.support.design.widget.TabLayout
                    android:id="@+id/home_Sub_TabLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabTextAppearance="@style/MineCustomTabText"
                    app:tabSelectedTextColor="@color/colorPrimary"
                    app:tabIndicatorColor="@color/colorPrimary"
                    app:tabTextColor="#858585"
                    app:tabMode="fixed"
                    app:tabGravity="fill"/>
                <android.support.v4.view.ViewPager
                    android:id="@+id/home_Sub_Viewpager"
                    android:layout_width="match_parent"
                    android:layout_height="400dp">
                </android.support.v4.view.ViewPager>
            </LinearLayout>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

And here is xml for Subtab1 which is a recyclerView:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
    android:id="@+id/trending_recycler_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>

</LinearLayout>

Im unable to scroll the recyclerView(Tab1-> subtab1->RecyclerView)Can somebody help me with the solution... Thanks in Advance PS: If there is any Doubt wrt to understanding of the issue pls do comment..

Duff answered 4/11, 2016 at 18:33 Comment(4)
I think your RecyclerView is messing up with NestedScrollView because both have scrolling properties and might be interfering with each other.Slipon
@ShadabAnsari recyclerView.setNestedScrollingEnabled(false) i have already disabled nested scroll in tat case it would scroll but scroll wouldnt be smooth... in My case the recycler view is not scrolling at all..Duff
I am facing similar problem, is there no solution for it.Ng
@SriramCG this was done by me 3 years ago but now my approach to solve this problem would be instead of using "Tablayout with viewpager" inside another viewpager we can create a view that looks like a tablayout (something like linearlayout with strips in horizontal orientation with click to select logic) to make it look like a tablayout and below it will be another layout which gets inflated as the tabs selected from your look alike tablayout and put everything in a single fragment of viewpager in nested scrollview. Hope u got what i'm trying to sayDuff

© 2022 - 2024 — McMap. All rights reserved.