2016-05-04 13 views
0

Meine App verfügt über eine Symbolleiste, die ausgeblendet wird, wenn Sie den Bildschirm nach unten scrollen und erscheint, wenn Sie mit dem Bildlauf beginnen.Leere Symbolleiste beim Scrollen

In Lollipop funktioniert es perfekt, aber in Kitkat wird manchmal eine leere Symbolleiste angezeigt, wenn Sie nach oben scrollen. Wenn Sie ein wenig nach unten scrollen, zeigt die Symbolleiste den richtigen Inhalt an.

Fehle ich etwas?

Hier ist ein Teil meiner xml:

<android.support.design.widget.CoordinatorLayout android:id="@+id/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" 
tools:context=".main.MainActivity"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#000"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:fitsSystemWindows="true" 
     app:layout_scrollFlags="scroll|enterAlways"> 

     <TextView 
      android:id="@+id/toolbarTitle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Card Name" 
      android:textColor="#fff" 
      android:textSize="18sp" 
      android:textStyle="bold"/> 
    </android.support.v7.widget.Toolbar> 

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

... 

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

Antwort

0

Legen Sie eine leere Ansicht unten Ihre Toolbar vor der AppBarLayout Schlusserklärung.

<android.support.design.widget.CoordinatorLayout android:id="@+id/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" 
tools:context=".main.MainActivity"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#000"> 

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:fitsSystemWindows="true" 
    app:layout_scrollFlags="scroll|enterAlways"> 

    <TextView 
     android:id="@+id/toolbarTitle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Card Name" 
     android:textColor="#fff" 
     android:textSize="18sp" 
     android:textStyle="bold"/> 

</android.support.v7.widget.Toolbar> 

<View 
     android:id="@+id/appbar_bottom" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="@android:color/transparent" 
     android:visibility="invisible" /> 

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

... 

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