2015-11-29 11 views
11

Ich habe ein Problem mit meiner Statusleiste, die von der Symbolleiste überlappt wird.Symbolleiste überlappt Statusleiste

Ich wollte die Funktion haben, dass, wenn der Benutzer die ListView nach unten scrollt, die Symbolleiste hinter der Statusleiste verschwindet, so dass nur die Registerkarten sichtbar sind, genau wie in den WhatsApp- und YouTube-Apps.

Um diesen Effekt zu erreichen oder diese Funktion ich diese Zeile verwendet zu bekommen:

app:layout_scrollFlags="scroll|enterAlways" 

in meine android.support.v7.widget.Toolbar, aber weiß, wie ich schon sagte, die Statusleiste von der Symbolleiste überlappt wird.

enter image description here

enter image description here

enter image description here

<?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:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="@dimen/appbar_padding_top" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

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

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

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

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

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


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

Dankbar für jede Hilfe!

UPDATE:

v21 \ styles.xml

<resources>> 
    <style name="AppTheme.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
     <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
     <item name="android:statusBarColor">@android:color/transparent</item> 
    </style> 
</resources> 

styles.xml

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 
    <style name="AppTheme.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 
    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

</resources> 

enter image description here

+0

posten Bitte den Stil dieser Aktivität von Ihrem styles.xml verwendet – asadmshah

+0

@asadmshah ich meinen Beitrag aktualisiert – Ron

Antwort

15

Versuchen hinzufügen android:fitsSystemWindows="true"-android.support.design.widget.AppBarLayout oder @style/AppTheme.PopupOverlay Stil

+1

jetzt habe ich die Wirkung haben, die ich wollte, aber meine Mitteilung Bar weiß @mdtuyen – Ron

+1

können Sie 'setStatusBarColor (int Farbe)' in Code oder ändern Sie den Stil, um es zu beheben – phongvan

+2

Ich habe bereits einen anderen Weg gefunden @ color/colorPrimaryDark ist das okey oder werde ich damit Probleme haben? @mdtuyen – Ron

0

versuchen android:layout_height="?attr/actionBarSize" für android.support.v7.widget.Toolbar

2

Dies funktioniert für mich macht ein weißes Overlay auf dem Gerät Statusleiste (Problem nach dem Update in Frage)

Ich wechselte zu bekommen:

<item name="android:windowDrawsSystemBarBackgrounds">true</item> 

zu

<item name="android:windowDrawsSystemBarBackgrounds">false</item> 

in meiner Datei styles.xml

+2

In meinem Fall hat es eine normale Farbe der Statusleiste in schwarz geändert. – CoolMind

+0

@CoolMind siehe [link] (http://matthewwear.xyz/no-excuses-it-takes-5-mins-make-that-drawer-visible-under-your-status-bar-2/) es beschreibt, wie es in Details funktioniert –

+0

offizielle Docs zum gleichen Thema: https://developer.android.com/reference/android/R.attr.html#windowDrawsSystemBarBackgrounds –

3

in v21\styles.xml

entfernen <item name="android:statusBarColor">@android:color/transparent</item>

Verwandte Themen