Android应用程序条在灵活的空间中滚动,内容重叠

Android应用程序条在灵活的空间中滚动,内容重叠,android,android-collapsingtoolbarlayout,android-nestedscrollview,Android,Android Collapsingtoolbarlayout,Android Nestedscrollview,在我的布局中,我使用应用程序栏在灵活的空间中滚动重叠的内容 我在水平滚动视图的嵌套滚动视图中有一个按钮列表,我想在向上滚动时停止顶部(操作栏下方)的水平滚动按钮布局。如何做到这一点,请帮忙 以下是我的布局结构: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.and

在我的布局中,我使用应用程序栏在灵活的空间中滚动重叠的内容

我在水平滚动视图的嵌套滚动视图中有一个按钮列表,我想在向上滚动时停止顶部(操作栏下方)的水平滚动按钮布局。如何做到这一点,请帮忙

以下是我的布局结构:

<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:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="RtlHardcoded">

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

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            app:contentScrim="?colorPrimary"
            app:expandedTitleMarginBottom="94dp"
            app:expandedTitleTextAppearance="@style/CollapsingTextAppearance.Inverse"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:title="@string/app_name">

            // conatins my header view

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

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:behavior_overlapTop="38dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nestedScrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none">

            <android.support.v7.widget.CardView
                android:id="@+id/cardview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="@dimen/margin"
                app:cardBackgroundColor="@color/white"
                android:focusableInTouchMode="false"
                android:focusable="false"
                app:cardCornerRadius="10dp"
                app:cardElevation="4dp"
                app:contentPaddingBottom="16dp"
                app:contentPaddingLeft="0dp"
                app:contentPaddingRight="0dp">

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

                    <HorizontalScrollView
                        android:id="@+id/horizontalSV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fillViewport="true"
                        android:scrollbarSize="2dp">

                        .... // conatins buttons

                        .... // conatins my list view view

                        </HorizontalScrollView>

                    </LinearLayout>


                </android.support.v7.widget.CardView>
        </android.support.v4.widget.NestedScrollView>
    </android.support.v4.widget.SwipeRefreshLayout>
    </android.support.design.widget.CoordinatorLayout>

将代码更改为此。剪切代码并在cardview中使用滚动行为

<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:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="RtlHardcoded">

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

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            app:contentScrim="?colorPrimary"
            app:expandedTitleMarginBottom="94dp"
            app:expandedTitleTextAppearance="@style/CollapsingTextAppearance.Inverse"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:title="@string/app_name">

            // conatins my header view

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

     <android.support.v7.widget.CardView
                android:id="@+id/cardview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="@dimen/margin"
                app:cardBackgroundColor="@color/white"
                android:focusableInTouchMode="false"
                android:focusable="false"
                app:cardCornerRadius="10dp"
                app:cardElevation="4dp"
                app:contentPaddingBottom="16dp"
                app:contentPaddingLeft="0dp"
                app:contentPaddingRight="0dp">

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

                    <HorizontalScrollView
                        android:id="@+id/horizontalSV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fillViewport="true"
                        android:scrollbarSize="2dp">

                        .... // conatins buttons

                        .... // conatins my list view view

                        </HorizontalScrollView>

                    </LinearLayout>

     <android.support.v4.widget.SwipeRefreshLayout
      android:id="@+id/swipeLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:behavior_overlapTop="38dp"
      app:layout_behavior="@string/appbar_scrolling_view_behavior">

      <android.support.v4.widget.NestedScrollView
       android:id="@+id/nestedScrollView"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:scrollbars="none">


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

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


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

//conatins我的标题视图
.... // 科纳廷按钮
.... // conatins我的列表视图

将滑动布局移动到协调器布局按钮,好的,我会检查并通知您