带有paddingTop的NestedScrollView(RecyclerView),在行为采取行动之前滚动

时间:2016-05-22 09:38:23

标签: android behavior android-coordinatorlayout android-appbarlayout nestedscrollview

我有NestedScrollViewRecyclerViewpaddingTop = 60dp例如cliptopadding = false。我需要RecyclerViewAppBarLayout$ScrollingViewBehaviorAppBarLayout$ScrollingViewBehavior嵌套滚动操作之前滚动(消耗) 60dp 。我尝试在总共滚动到达60dp边界之前在setNestedScrollingEnabled(false)侦听器中禁用嵌套滚动RecyclerView.OnScrollListener而不是启用它,但是在向下滚动事件期间我遇到了很多问题。 那么是否有任何默认的实现技巧可以使所有工作。这是屏幕截图及其标准CoordinatorLayout xml文件

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:background="@android:color/white">

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

        <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:background="@android:color/transparent"
            android:fitsSystemWindows="true">

            <android.support.design.widget.AppBarLayout
                android:id="@+id/main.appbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/transparent"
                android:fitsSystemWindows="true"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/main.collapsing"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:minHeight="?actionBarSize"
                    app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
                    app:titleEnabled="false">

                    <android.support.design.widget.TabLayout
                        android:id="@+id/main.tab"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="bottom"
                        android:background="?attr/colorPrimary"
                        android:minHeight="?actionBarSize"
                        app:tabGravity="fill"
                        app:tabMaxWidth="0dp"
                        app:tabMode="fixed" />


                    <FrameLayout
                        android:id="@+id/main.backdrop"
                        android:layout_width="match_parent"
                        android:layout_height="200dp"
                        app:layout_collapseMode="parallax" />


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


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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">


                <android.support.v4.widget.NestedScrollView
                    android:id="@+id/aaabbb"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="20dp"
                    android:layout_marginRight="20dp"
                    android:paddingTop="60dp"
                    android:clipToPadding="false"
                    android:clipChildren="false"
                    android:background="@android:color/white"

                    >

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:lineSpacingExtra="8dp"
                        android:padding="@dimen/activity_horizontal_margin"
                        android:text="@string/lorem"
                        android:textSize="20sp" />
                </android.support.v4.widget.NestedScrollView>

            </LinearLayout>

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


    </LinearLayout>
</FrameLayout>

enter image description here

0 个答案:

没有答案