0

I use CoordinatorLayout for scrolling out ToolBar. When ToolBar scrolls out, the background of Notification bar scrolls out also. It looks ugly. How to freeze the background of Notification bar?

Red "hello" line is mock of additional bar element. It has to don't scroll out of screen.

Screenshots of scrolling from this

enter image description here

to this

enter image description here

Layout:

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="ru.jollydroid.collapsingtoolbardemo.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/AppTheme.PopupOverlay"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="@color/red"
            android:text="hello"/>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:behavior_overlapTop="64dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <include layout="@layout/content_main"/>
    </android.support.v4.widget.NestedScrollView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email"/>

</android.support.design.widget.CoordinatorLayout>

Full source: https://github.com/tseglevskiy/CollapsingToolbarDemo

tse
  • 5,769
  • 6
  • 38
  • 58

1 Answers1

0

Please remove the line

android:fitsSystemWindows="true"

from CoordinatorLayout Since the CoordinatorLayout shouldn't fit the whole system window.

Desdroid
  • 300
  • 2
  • 9