Android 将TabLayout固定到顶部,而下面的工具栏使用AppBarLayout滚动到顶部

Android 将TabLayout固定到顶部,而下面的工具栏使用AppBarLayout滚动到顶部,android,android-support-library,android-toolbar,android-design-library,android-appbarlayout,Android,Android Support Library,Android Toolbar,Android Design Library,Android Appbarlayout,我有一个我希望始终固定在顶部的TabLayout,在它下面有一个工具栏,当视图被滚动时,它会向上滚动到TabLayout中 <android.support.design.widget.CoordinatorLayout android:id="@+id/main_content" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.

我有一个我希望始终固定在顶部的TabLayout,在它下面有一个工具栏,当视图被滚动时,它会向上滚动到TabLayout中

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    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"
    tools:context=".main.MainActivity">



    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:animateLayoutChanges="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
            <android.support.design.widget.TabLayout
                android:id="@+id/tabLayout"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"/>


            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"/>

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

    <android.support.v4.widget.NestedScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/imageView2"
            android:src="@drawable/music_content"
            android:contentDescription="@string/image_chooser_title"
            />

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

</android.support.design.widget.CoordinatorLayout>
不为上面的TabLayout设置任何滚动标志,因为我希望它保持固定状态。但是,使用这些设置,AppBarLayout根本不会滚动。如果我向TabLayout添加一个滚动标志,那么它们都会滚动,TabLayout不会保持固定。当下面的工具栏向上滚动“屏幕外”时,是否有办法使表格布局保持固定

如果需要,可根据以下要求提供图片

注意:所有使用滚动标志的视图必须在不使用该标志的视图之前声明。这样可以确保所有视图都从顶部退出,保留固定图元


因此,使用
AppBarLayout

无法实现您想要的功能。您好,请告诉我如何实现Foursquare应用程序滚动行为,如下所示:。
app:layout_scrollFlags="scroll|enterAlways"