2017-04-26 5 views
2

In meinem Layout habe ich CollapsingToolbar Layout innerhalb AppBarLayout, die unter Statusleiste wie vorgesehen zeichnet. Mein Layout XML ist als untenzusammenklappbare Symbolleiste zeigt zusätzlichen Abstand

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

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/toolbar_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:titleEnabled="false" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlways|snap"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:foreground="@drawable/header_overlay" 
       android:scaleType="fitXY" 
       android:fitsSystemWindows="true" 
       android:src="@drawable/project_list_header" 
       app:layout_collapseMode="parallax"/> 


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

      <TextView 
       android:id="@+id/text_search" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="?attr/actionBarSize" 
       android:layout_marginTop="?attr/actionBarSize" 
       android:layout_marginLeft="@dimen/spacing_16" 
       android:layout_marginRight="@dimen/spacing_16" 
       android:background="@drawable/search_background" 
       android:drawableLeft="@drawable/ic_search_black" 
       android:drawablePadding="@dimen/spacing_12" 
       android:gravity="center_vertical" 
       android:layout_gravity="bottom" 
       android:hint="@string/search_project_hint" 
       android:paddingBottom="@dimen/spacing_14" 
       android:paddingLeft="@dimen/spacing_14" 
       android:paddingRight="@dimen/spacing_14" 
       android:paddingTop="@dimen/spacing_14" 
       android:textColorHint="@color/black_70" 
       android:textSize="@dimen/text_14" 
       tools:hint="@string/search_project_hint"> 
      </TextView> 
      <android.support.design.widget.TabLayout 
       android:id="@+id/tab_layout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       app:layout_collapseMode="pin" 
       app:tabGravity="fill" 
       app:tabMode="fixed"/> 

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


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

Dies gibt dem Bildschirm unten

Normal image

Aber wenn ich nach unten scrollen, gibt es zusätzlichen schwarzen Abstand in der oberen und im unteren Teil des AppBarLayout

Extra spacing

Und wenn ich enterAlways Flagge vonentfernen, dann ist der zusätzliche Abstand weg, aber AppBar wird nicht angezeigt, wenn ich nach oben scrolle.

Also, wie man diesen Abstand entfernen und AppBar beim Scrollen anzeigen?

Antwort

0

Es ist zu spät, um zu antworten, aber ich denke, diese Lösung vielleicht hilfreich für Sie: -

 <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsing_toolbar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     app:contentInsetRight="0dp" 
     app:contentInsetEnd="0dp" 
     android:contentInsetRight="0dp" 
     android:contentInsetEnd="0dp" 
     android:paddingEnd="0dp" 
     android:paddingTop="0dp" 
     app:layout_collapseMode="parallax" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" 
     app:titleEnabled="false"> 
Verwandte Themen