向下滚动时如何避免隐藏选项卡?

how to avoid hiding the tabs when scrolled down?

我已经用 TabLayout 实现了 viewpager。每个选项卡都是一个片段。我认为 Tabs 的默认行为是当用户向下滚动时隐藏它们并在向上滚动时获得可见性。

我也没有太多内容可以使用选项卡 space。所以我想一直显示标签。
如何避免在用户向下滚动时隐藏选项卡?

这是我的带有 ViewPager 的 TabLayout:

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

    <android.support.design.widget.TabLayout
        android:id="@+id/myTabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/toolbar_height"
        android:background="@color/white"
        android:overScrollMode="never"
        app:layout_scrollFlags="scroll|enterAlways"
        app:tabIndicatorColor="@color/white"
        app:tabIndicatorHeight="3dp"
        app:tabMode="scrollable" />
</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/myViewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

Play 商店中的应用程序页面始终显示标签。

取消这条线

app:layout_scrollFlags="scroll|enterAlways"

此标志强制视图(您的 TabLayout)在任何向下滚动事件滚动事件

<android.support.design.widget.TabLayout
        android:id="@+id/myTabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/toolbar_height"
        android:background="@color/white"
        android:overScrollMode="never"
        app:tabIndicatorColor="@color/white"
        app:tabIndicatorHeight="3dp"
        app:tabMode="scrollable" />