0

I am using TabLayoutBar for showing tabs. But it somehow eclipsed my ToolBar. The issues is happening on API v21 and not on API v15.

Following is my layout:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <!-- Scrollable views -->
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|enterAlways"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <include layout="@layout/home_activity_toolbar" />

        <android.support.design.widget.TabLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:id="@+id/tabLayout">
        </android.support.design.widget.TabLayout>
    </android.support.design.widget.AppBarLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="4dp"
        android:background="@drawable/shadow" />

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

And here is what is looks like on Lollipop:

enter image description here

N J
  • 27,217
  • 13
  • 76
  • 96
Rajat Saxena
  • 3,834
  • 5
  • 45
  • 63

1 Answers1

1

You should use layout_scrollFlags on AppBarLayout's children not on itself

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

    <include layout="@layout/home_activity_toolbar"
        app:layout_scrollFlags="scroll|enterAlways" />

    <android.support.design.widget.TabLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:id="@+id/tabLayout">
    </android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
steven274
  • 3,321
  • 2
  • 10
  • 11