2016-05-26 12 views
0

Ich habe einen seltsamen Bug in meinem Layout und ich kann es nicht herausfinden. Ein weißer Balken erscheint zwischen meinen Fragmenten und TabLayout. Ich habe diesen Code für eine Weile nicht geändert, vielleicht ist es etwas in Android 6.0.1 (ich habe ein Nexus 5). Ich bin mir ziemlich sicher, dass es in 6.0 oder in Lollipop keinen Bug gab. HierSeltsame weiße Balken erscheint zwischen TabLayout und Fragment

ist ein Screenshot:

enter image description here

Dies ist meine Aktivität 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> 

Jede Idee?

UPDATE 1:

Nach dem Vorschlag von @Abanoub Samaan mein Layout sieht wie folgt aus:

enter image description here

UPDATE 2:

Der Fehler erscheint auch auf meiner Nexus 7 (2012) mit Android 5.1.1 Lollipop.

Antwort

0

ich es herausgefunden.

änderte ich wieder auf eine ältere Version der Support-Bibliothek wie:

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

Jetzt ist mein Layout ist wieder normal:

enter image description here

2

Setzen Sie nicht die Höhe des CollapsingToolbarLayout

android:layout_height="142dp" 

ersetzen Sie es durch

android:layout_height="wrap_content" 
+0

es nicht funktioniert, sehen Sie das Update in meiner Frage. – zkminusck

+0

Versuchen Sie, die TabLayout-Höhe auf "? Attr/actionBarSize" zu setzen, nicht auf "wrap_content" –

+0

Die Höhe der Symbolleiste ist im Moment auf "? Attr/actionBarSize" eingestellt. – zkminusck

0

ich eine andere Situation hatte. Ich werde es hier teilen, nur für den Fall, dass jemand da draußen es nützlich finden könnte.

war meine Struktur in activity_main.xml wie folgt:

DrawerLayout 
    |_ CoordinatorLayout 
     |_ Toolbar 
     |_ FrameLayout 

den seltsamen Raum zu beheben, die unter dem TabLayout erscheint ich die CoordinatorLayout mit einem RelativeLayout geändert.

0

Wie Abdelalim hatte ich das gleiche Problem mit einer anderen Situation.

In meiner Haupttätigkeit hatte ich

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

ich einige Fragmente hatte im framelayout gemacht zu werden. In einem der Fragmente hatte ich einen CoordinatorLayout mit

android:fitsSystemWindows="true" 

Ich entfernte genau das und es funktionierte