An android newbie is here :-) I am studying CoordinatorLanyout in material designing. So I tried to implement TabLayout inside CoordinatorLanyout and it worked fine. But I implemented the RecyclerView inside one fragment for ViewPager and faced a strange scrolling issue. The list is not scrolling now. I surfed and tried lot of solutions here but nothing can fix this issue. here am is my activity_main.xm
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:local="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
android:elevation="8dp"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="20dp"
app:expandedTitleMarginEnd="10dp">
<include
android:id="@+id/counter_id"
layout="@layout/counter_layout"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:elevation="8dp"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/pager_tab_id"
android:background="@color/colorPrimary"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:layout_gravity="bottom"
app:tabMode="scrollable"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:id="@+id/container_body"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
here the frame layout for replacing the fragments. so the viewpager will take this frame container.
Am using this xml for set the viewPager layout which will use the FrameLayout in the activity_main.xml that i mentioned above
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context="bodhi.electionpoll.ui.fragment.PanchayathHistoryFragment">
<android.support.v4.view.ViewPager
android:id="@+id/content_panchayath_hisory_pager"
android:background="@color/windowBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
next i designed a xml for RecyclerView adapter
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipe_container_service"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent">
<SearchView
android:id="@+id/search"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textSize="16sp"
android:hint="Search here"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_list"
android:layout_below="@+id/search"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fillViewport="true"
android:layout_marginTop="4dp"
/>
</RelativeLayout>
i think no need to mention related java files
after implementation of these, the scrolling is not working
Your structure should be like this ->
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout>
<Layout/>
<Toolbar/>
</CollapsingToolbarLayout>
<TabLayout/>
</AppBarLayout>
<ViewPager/>
</CoordinatorLayout>
i think you will understand.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.