1

Here, i am using collapsing toolbar which includes slider on top, two horizontal item listing by recyclerview in the middle and tablayout. I have used tablayout for category listing. Now, i have this one problem, whenever i scroll upward fast then the view bounces back downward. I want to pin toolbar and tablayout o the screen.

Here is my design:

enter image description here

The layout is given below:

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#060C18"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:fitsSystemWindows="true"
    app:layout_anchorGravity="bottom"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.design.widget.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/livetv_bg_list"
        android:fitsSystemWindows="true"
        app:titleEnabled="false"
        app:contentScrim="#060C18"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

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

            <RelativeLayout
                android:id="@+id/banner_relative_layout"
                android:layout_width="match_parent"
                android:layout_height="370dp">
                <com.newitventure.nettv.nettvapp.ott.utils.AutoScrollViewPager
                    android:id="@+id/movieslider"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="?attr/actionBarSize"
                    android:gravity="right|end"
                    android:paddingRight="10dp">

                    <me.relex.circleindicator.CircleIndicator
                        android:id="@+id/indicator"
                        android:layout_width="wrap_content"
                        android:layout_height="40dp"
                        android:layout_marginTop="20dp"
                        app:ci_drawable="@drawable/banner_indicator_color"
app:ci_drawable_unselected="@drawable/banner_unselected_indicator_color" />

                </RelativeLayout>

            </RelativeLayout>

            <LinearLayout
                android:id="@+id/main_linear"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/banner_relative_layout"
                android:background="#060C18"
                android:orientation="vertical"
                android:visibility="visible">

                <RelativeLayout
                    android:id="@+id/recently_added_relative_layout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_below="@+id/banner_relative_layout"
                    android:layout_marginBottom="16dp"
                    android:layout_marginTop="16dp"
                    android:visibility="gone">

                    <TextView
                        android:id="@+id/recently_added_tv"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="RECENTLY ADDED"
                        android:textColor="#fff" />

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/movie_recently_added_recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/recently_added_tv"
                        android:layout_marginTop="8dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentRight="true"
                        android:layout_marginEnd="16dp"
                        android:layout_marginRight="16dp"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="SEE MORE"
                            android:textColor="#ff7b52" />

                        <View
                            android:layout_width="match_parent"
                            android:layout_height="2dp"
                            android:background="#ff7b52" />

                    </LinearLayout>

                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/continue_watching_relative_layout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
android:layout_below="@+id/recently_added_relative_layout"
                    android:layout_marginBottom="16dp"
                    android:visibility="visible">

                    <TextView
                        android:id="@+id/continue_watching_tv"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="CONTINUE WATCHING"
                        android:textColor="#fff" />

                    <android.support.v7.widget.RecyclerView
                      android:id="@+id/movie_continue_watching_recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_below="@id/continue_watching_tv"
                        android:layout_marginTop="8dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentRight="true"
                        android:layout_marginEnd="16dp"
                        android:layout_marginRight="16dp"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="SEE MORE"
                            android:textColor="#ff7b52" />

                        <View
                            android:layout_width="match_parent"
                            android:layout_height="2dp"
                            android:background="#ff7b52" />

                    </LinearLayout>

                </RelativeLayout>

            </LinearLayout>

        </RelativeLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin">

            <ImageView
                android:id="@+id/ham_menu"
                android:layout_width="24dp"
                android:layout_height="24dp"
                android:layout_marginLeft="16dp"
                android:layout_marginTop="16dp"
                android:src="@drawable/menu" />

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

        <android.support.design.widget.TabLayout
            android:id="@+id/movie_categories"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/main_linear"
            android:background="#060C18"
            app:tabGravity="center"
            app:tabIndicatorColor="#ff7b52"
            app:tabIndicatorHeight="4dp"
            app:tabMode="scrollable"
            app:tabSelectedTextColor="#DDDDDD"
            app:tabTextColor="#9095A0" />

        <android.support.v4.view.ViewPager
            android:id="@+id/movie_categories_detail_list"
            android:layout_width="match_parent"
            android:layout_height="500dp"
            android:layout_marginTop="8dp" />

    </LinearLayout>

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

<Button
    android:id="@+id/movie_categories_view_all"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="View All"
    android:visibility="gone" />

<ProgressBar
    android:id="@+id/movie_progress"
    style="?android:attr/progressBarStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:layout_gravity="center"
    android:visibility="visible" />

<com.newitventure.nettv.nettvapp.search.MeroListView
    android:id="@+id/search_listview"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_marginTop="50dp"
    android:background="@drawable/list_view_bg"
    android:divider="@null"
    android:visibility="gone" />

Please help me out!!

Zain
  • 37,492
  • 7
  • 60
  • 84
Kabindra Shrestha
  • 333
  • 2
  • 6
  • 17
  • duplicate of [this post](https://stackoverflow.com/questions/45192654/how-to-avoid-collapsingtoolbarlayout-not-being-snapped-or-being-wobbly-when-sc). Check it out – usernotnull Feb 01 '18 at 16:25
  • @RJFares This question is not duplicate of above post. Its far more different. I want my collapsing toolbar not to bounce back toward downward whenever i scroll it fast. I have updated the question with designs. Please help me out. – Kabindra Shrestha Feb 07 '18 at 11:39

0 Answers0