Viewpager does not scroll at coordinator location

This is my layout.

<?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:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="280dp" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapse_toolbar" android:layout_width="match_parent" android:layout_height="250dp" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="100dp" android:gravity="top" android:minHeight="?attr/actionBarSize" app:layout_collapseMode="pin" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:titleMarginTop="15dp"> </android.support.v7.widget.Toolbar> <android.support.design.widget.TabLayout android:id="@+id/category_tabs" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_gravity="bottom" android:background="#f0f0f0" android:focusable="false" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/talview_color_1" /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.CoordinatorLayout> 

I am trying to pull the tablayout from above while scrolling. This does not work. More importantly, there is a listview in each viewpager fragment, and scrolling does not work in the list.

Can anybody help

+5
source share
1 answer

You need to use the NestedScrollView provided in Android Support Library v4, which is designed to work with CoordinatorLayout

 <android.support.v4.widget.NestedScrollView ...> <LinearLayout ...> ... </LinearLayout> </android.support.v4.widget.NestedScrollView> 

or RecyclerView , note that the classic ListView does not work with CoordinatorLayout.

therefore, inside the viewPager, you must have NestedScrollView or RecyclerView

Good luck.

+14
source

Source: https://habr.com/ru/post/1238640/


All Articles