-1

I have Fragment which contains a Nested Scroll View in it. Inside this Nested Scroll View there is a View Pager and recycle view.When I am scroll the view only recycle view scroll,View Pager not scrolling.I want to scroll recycle view and view pager.I try many way but not success.please help me.....

<?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:custom="http://schemas.android.com/tools"
    android:id="@+id/timeline_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00000000"
    android:orientation="vertical"
    android:tag="timeline_fragment">

    


    <androidx.core.widget.NestedScrollView
        android:id="@+id/nst_scrollview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/crv_profile_visit"
        android:layout_weight="1"
        android:fillViewport="true"
        android:overScrollMode="never"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">


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

            <RelativeLayout
                android:id="@+id/rl_view_pager"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_140sdp"
                android:visibility="gone"">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center">

                    <!-- <com.customView.CustomViewPager
                         android:id="@+id/viewPager"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_gravity="center"
                         android:nestedScrollingEnabled="true"
                         app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
-->

                    <androidx.viewpager.widget.ViewPager
                        android:id="@+id/viewPager"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center" />
                </LinearLayout>


                <com.ViewPagerWithIndicator.TimelineFragmentViewPageWithIndicator
                    android:id="@+id/timelineViewPagerWithIndicator"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_centerInParent="true"
                    android:layout_centerHorizontal="true"
                    app:arrow.enable="true"
                    app:arrow.height_="50dip"
                    app:arrow.width_="50dip"
                    app:left_arrow.drawable="@drawable/arrow_left_promotion"
                    app:right_arrow.drawable="@drawable/arrow_right_promotion"
                    app:round.color.default="@android:color/white"
                    app:round.color.selected="@android:color/holo_blue_light"
                    app:round.drawable="@drawable/background_rounded_view_pager_indicater"
                    app:round.enable="true"
                    app:round.size="15dip">

                </com.ViewPagerWithIndicator.TimelineFragmentViewPageWithIndicator>


            </RelativeLayout>

            <ImageView
                android:id="@+id/img_no_feed"
                android:layout_width="@dimen/_100sdp"
                android:layout_height="@dimen/_100sdp"
                android:layout_centerInParent="true"
                android:visibility="gone" />

            <androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/swiperefresh"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">


                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/recycleview_user_time_line"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="@dimen/_3sdp"
                    android:nestedScrollingEnabled="true" />
            </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
        </LinearLayout>


    </androidx.core.widget.NestedScrollView>


    <LinearLayout
        android:id="@+id/ll_create_post"
        android:layout_width="@dimen/_170sdp"
        android:layout_height="@dimen/_200sdp"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:gravity="center"
        android:orientation="vertical"
        android:visibility="visible">


        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/fab_poll"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right|center"
            android:layout_margin="8dp"
            android:gravity="center"
            android:text="@string/txt_timeline_fragment_poll"
            android:textColor="@android:color/holo_red_dark"
            android:visibility="invisible"
            app:backgroundTint="@android:color/holo_orange_light"
            app:rippleColor="@android:color/holo_red_light" />

        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/fab_post"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right|center"
            android:layout_margin="8dp"
            android:gravity="center"
            android:text="@string/txt_timeline_fragment_post"
            android:textColor="@android:color/white"
            android:visibility="invisible"
            app:backgroundTint="@android:color/holo_orange_light"
            app:rippleColor="@android:color/holo_red_light" />

        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right|center"
            android:layout_margin="8dp"
            android:textColor="@android:color/holo_red_dark"
            app:backgroundTint="@android:color/holo_orange_light"
            app:icon="@drawable/ic_float_button"
            app:iconTint="@android:color/white"

            app:rippleColor="@android:color/holo_red_light" />


        

    </LinearLayout>


</RelativeLayout>
  • where is `crv_profile_visit` – aryan agarwal Sep 15 '20 at 08:29
  • Does this answer your question? [How to use RecyclerView inside NestedScrollView?](https://stackoverflow.com/questions/31000081/how-to-use-recyclerview-inside-nestedscrollview) – Ryan M Sep 18 '20 at 09:11
  • No, with recycle view there in no problem.I am used view pager to show multiple image swipe automatically one by one with three dot.My problem is that only recycle view scrolling....View pager unable to scroll.I want both scroll.If any fault in my design please suggest.I don't know who given negative vote to me i am new in here.If possible remove negative vote. – Gopinath Chakrabortty Sep 19 '20 at 06:20

1 Answers1

0

Remove NestedScrollView, Use ListView instead of RecyclerView and put viewpager in header of listview with addHeaderView method.

Saeed
  • 552
  • 2
  • 6
  • 18
  • In RecyclerView lot of work did in this fragment so, unable to change recycle view.If any other solution please let me know. – Gopinath Chakrabortty Sep 15 '20 at 13:28
  • if you cant change recyclerview to list view, add viewpager as header in recyclerview and remove NestedScrollView. https://www.skcript.com/svr/how-to-add-header-to-recyclerview-in-android/ – Saeed Sep 15 '20 at 15:36