how to avoid hiding the tabs when scrolled down?
Asked Answered
A

1

2

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 ?

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

Apps page in Play store always shows the tabs.

Angeli answered 18/11, 2015 at 10:52 Comment(0)
C
4

Take off this line

app:layout_scrollFlags="scroll|enterAlways"

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" />
Carthusian answered 18/11, 2015 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.