2015-12-18 1 views
3

Je tente de masquer la barre d'outils pendant le défilement, mais cela arrive! Qu'est-ce que je dois faire?La barre d'outils ne se cache pas complètement sur le défilement

Voici le code de mise en page:

<?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.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/SimpleTheme.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" 
     app:popupTheme="@style/SimpleTheme.PopupOverlay" /> 

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

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

<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.support.design.widget.CoordinatorLayout> 

Le conteneur de vue a comportement suivant:

app:layout_behavior="@string/appbar_scrolling_view_behavior" 

Captures d'écran: Before scroll After scroll

+0

Avez-vous utilisé 'windowDrawSystemBackgrounds' dans votre thème? – Heinrich

Répondre

9

Il y a quelque chose avec 'fitsSystemWindows' Rendre false dans coordinatorLayout et true dans AppBarLayout

+1

Merci! Ça marche! –

+1

cela fonctionne partiellement, mais de toute façon je perds l'effet colorPrimaryDark de la barre d'état –

+0

Great. Travaux. Pourquoi cette réponse n'est-elle pas acceptée? @ Jan-LkElse – ahmadalibaloch