0

I am using nesterdscrollview and inside a viewpager for tablayout and inside a fragment of tablayout I am using recycler view I disable recyclerview nesterscrolling and want to scroll with nested scrollview but not working nothing scrolling. I check viewpager to set wrap_content and match_parent height but still not working not scrolling nesterdscrollview. Please guide me how to scroll nestedscrollview with viepager2 or viewpager

<androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_transparent"
            app:elevation="0dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <com.google.android.material.appbar.MaterialToolbar
                android:id="@+id/am_toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:menu="@menu/top_menu" />
        </com.google.android.material.appbar.AppBarLayout>

        <androidx.core.widget.NestedScrollView
            android:id="@+id/fm_scrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

                <LinearLayout
                    android:id="@+id/history_parent_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:visibility="@{history>0 ?View.VISIBLE :View.GONE}">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center_vertical"
                        android:padding="10dp">

                        <TextView
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="History"
                            android:textColor="@color/white"
                            android:textSize="16sp"
                            android:textStyle="bold" />

                        <androidx.appcompat.widget.AppCompatImageButton
                            android:id="@+id/fmv_clear_history"
                            android:layout_width="20dp"
                            android:layout_height="20dp"
                            android:layout_gravity="end|center_vertical"
                            android:src="@drawable/ic_delete" />
                    </LinearLayout>

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/fmv_historyRecyclerview"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="10dp"
                        android:layout_marginBottom="10dp"
                        android:nestedScrollingEnabled="true"
                        android:orientation="horizontal"
                        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                        tools:listitem="@layout/item_video_history" />
                </LinearLayout>

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

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:baselineAligned="false"
                        android:orientation="horizontal"
                        android:padding="10dp">

                        <com.google.android.material.tabs.TabLayout
                            android:id="@+id/mainVideoTab"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            app:layout_constraintStart_toStartOf="parent"
                            app:layout_constraintTop_toTopOf="parent"
                            app:tabGravity="center"
                            app:tabIndicator="@drawable/tabs_indicator"
                            app:tabIndicatorAnimationDuration="100"
                            app:tabIndicatorColor="@color/primaryColor"
                            app:tabIndicatorFullWidth="false"
                            app:tabIndicatorHeight="20dp"
                            app:tabRippleColor="@null"
                            app:tabSelectedTextColor="@color/primaryColor"
                            app:tabTextAppearance="@style/CustomTextStyle"
                            app:tabTextColor="@color/white">

                            <com.google.android.material.tabs.TabItem
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="@string/video" />

                            <com.google.android.material.tabs.TabItem
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="@string/folder" />
                        </com.google.android.material.tabs.TabLayout>

                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_weight="1"
                            android:gravity="end"
                            android:orientation="horizontal">

                            <androidx.appcompat.widget.AppCompatImageView
                                android:id="@+id/fmv_sort_item"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:background="@android:color/transparent"
                                android:clickable="true"
                                android:focusable="true"
                                android:foreground="?android:selectableItemBackground"
                                android:rotation="90"
                                android:src="@drawable/ic_swap"
                                android:visibility="@{tabPosition ==0 ? View.VISIBLE : View.GONE}"
                                app:tint="@color/white"
                                tools:targetApi="m" />

                            <androidx.appcompat.widget.AppCompatImageView
                                android:id="@+id/fmv_switchVideoView"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="10dp"
                                android:background="@android:color/transparent"
                                android:clickable="true"
                                android:focusable="true"
                                android:foreground="?android:selectableItemBackground"
                                android:src="@drawable/ic_list"
                                android:visibility="@{tabPosition ==0 ? View.VISIBLE : View.GONE}"
                                app:tint="@color/white"
                                tools:targetApi="m" />

                            <androidx.appcompat.widget.AppCompatImageView
                                android:id="@+id/fmv_switchFolderView"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="10dp"
                                android:background="@android:color/transparent"
                                android:clickable="true"
                                android:focusable="true"
                                android:foreground="?android:selectableItemBackground"
                                android:src="@drawable/ic_list"
                                android:visibility="@{tabPosition ==1 ? View.VISIBLE : View.GONE}"
                                app:tint="@color/white"
                                tools:targetApi="m" />
                        </LinearLayout>
                    </LinearLayout>

                    <androidx.viewpager2.widget.ViewPager2
                        android:id="@+id/mainVideoViewPager"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:nestedScrollingEnabled="false"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/mainVideoTab" />

                </LinearLayout>
            </LinearLayout>
        </androidx.core.widget.NestedScrollView>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

I tried by creating custom viepager2 to disable ontouchlistener and set touchlistener to nestedscrollview but still not worked and tyr to change height of viewpager to wrap_content and match_parent

2
  • In viepager2 make android:nestedScrollingEnabled="true". This will work. Commented Jun 1, 2023 at 19:03
  • @Vinay i tried not working app crashing Commented Jun 2, 2023 at 20:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.