0

I got a wierd bug in my layout and I can't figure it out. A white bar appears between my Fragments and TabLayout. I didn't changed this code for a while now, maybe it's something in Android 6.0.1 (I got a Nexus 5). I'm pretty sure, that there was no bug in 6.0 or in Lollipop.

Here is a screenshot:

enter image description here

This is my Activity XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_below="@+id/tablayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="142dp"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginBottom="20dp"
            app:expandedTitleMarginEnd="48dp"
            app:expandedTitleTextAppearance="@style/ExpandedText"
            app:collapsedTitleTextAppearance="@style/CollapsedText">
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:minHeight="?attr/actionBarSize"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin"/>
            </android.support.design.widget.CollapsingToolbarLayout>
        <android.support.design.widget.TabLayout
            android:id="@+id/tablayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:minHeight="?attr/actionBarSize"
            android:gravity="bottom"
            android:background="?attr/colorPrimary"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:tabIndicatorColor="?attr/colorPrimaryDark"/>
        </android.support.design.widget.AppBarLayout>
    </android.support.design.widget.CoordinatorLayout>

Any idea?

UPDATE 1:

After the suggestion of @Abanoub Samaan my layout looks like this:

enter image description here

UPDATE 2:

The bug also appears on my Nexus 7 (2012) running Android 5.1.1 Lollipop.

zkminusck
  • 1,230
  • 1
  • 12
  • 23

4 Answers4

3

Like Abdelalim I had the same problem with a different situation.

In my main activity i had

<RelativeLayout>
    <FragmenLayout></FrameLayout>
    <android.support.design.widget.BottomNavigationView><android.support.design.widget.BottomNavigationView
</RelativeLayout>

I had a few fragments being rendered in the framelayout. In one of the fragments I had a CoordinatorLayout with

android:fitsSystemWindows="true"

I just removed that and it worked

kidustiliksew
  • 443
  • 3
  • 11
2

Don't set the height of the CollapsingToolbarLayout

android:layout_height="142dp"

replace it by

android:layout_height="wrap_content"
Abanoub Samaan
  • 226
  • 1
  • 5
  • 11
0

I figured it out.

I changed back to an older version of the support library like:

compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'

Now my layout is back to normal:

enter image description here

zkminusck
  • 1,230
  • 1
  • 12
  • 23
0

I had a different situation. I'll share it here just in case someone out there could find it useful.

My structure in activity_main.xml was as follows:

DrawerLayout
    |_ CoordinatorLayout
        |_ Toolbar
        |_ FrameLayout

To fix the weird space that appears under the TabLayout I changed the CoordinatorLayout with a RelativeLayout.