当向下滚动如何避免隐藏标签? [英] how to avoid hiding the tabs when scrolled down?

查看:155
本文介绍了当向下滚动如何避免隐藏标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现viewpager与TabLayout。每个选项卡是一个片段。我认为标签的默认行为是,他们是隐藏用户向下滚动时,当向上滚动获得知名度。

I have implemented viewpager with TabLayout. Each tab is a Fragment. I think the default behavior of Tabs is that they are hidden when user scrolls down and gets visibility when scrolled up.

我不会有太多的内容,以充分利用标签的空间了。所以我想始终显示的选项卡。结果
我怎样才能避免隐藏标签当用户滚动下来?

I wont have much content to make use of the tabs space too. So I want to show the tabs always.
How can I avoid hiding the Tabs when user scrolls down ?

下面是我用TabLayout ViewPager:

Here is my TabLayout with ViewPager:

<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商店应用页面始终显示标签。

Apps page in Play store always shows the tabs.

推荐答案

脱下这行

app:layout_scrollFlags="scroll|enterAlways"

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

this flag forces the view (your TabLayout) to scroll on any downwards scroll event.

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

这篇关于当向下滚动如何避免隐藏标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆