折叠工具栏在快速滚动后反弹回来

时间:2018-01-17 11:20:26

标签: java android android-studio android-collapsingtoolbarlayout android-appbarlayout

在这里,我正在使用折叠工具栏,其中包括顶部的滑块,中间的两个水平项目列表以及tablayout中的recyclerview。我已经使用tablayout进行类别列表。现在,我有这个问题,每当我快速向上滚动,然后视图向下反弹。我想在屏幕上固定工具栏和tablayout。

这是我的设计:

enter image description here

布局如下:

<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" />

请帮帮我!!

0 个答案:

没有答案