10

Ich versuche Collapsing Toolbar mit Home/Up-Taste zu verwenden. Nach dem Zusammenbruch der Symbolleiste gibt es einen zusätzlichen Abstand zwischen Pfeil und Titel, den ich gerne loswerden möchte. Ich habe zwei Bilder mit und ohne Layoutgrenzen angehängt, um meinen Standpunkt zu verdeutlichen.Zusätzlicher Platz zwischen Collapsing Toolbar Title und Home/Up-Taste

Ich suchte StackOverflow und überall und versuchte android: contentInsetStart = "0DP" umsonst.

enter image description here

enter image description here

Hier ist mein Layout XML-Datei.

<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:orientation="vertical"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="300dp" 
     android:background="?colorPrimary" 
     app:elevation="4dp"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar_layout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="?attr/colorPrimary" 
      app:collapsedTitleTextAppearance= 
       "@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse" 
      app:contentScrim="?attr/colorPrimary" 
      app:expandedTitleTextAppearance= 
       "@style/TextAppearance.ExpandedTitle" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      app:title="Toolbar Title"> 


      <ImageView 
       android:id="@+id/collapsing_toolbar_background" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="88dp" 
       android:contentDescription="@string/app_name" 
       android:scaleType="centerCrop" 
       android:src="@drawable/glider" 
       app:layout_collapseMode="parallax" 
       /> 

      <View 
       android:id="@+id/toolbar_title_scrim" 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:layout_alignBottom="@+id/collapsing_toolbar_background" 
       android:layout_gravity="bottom" 
       android:background="@android:color/holo_green_light"/> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       android:text="test text" 
       android:textColor="@android:color/white"/> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:contentInsetStart="0dp" 
       android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
       app:layout_collapseMode="pin"/> 

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

    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/swipe_refresh_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycler_view" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:clipToPadding="false" 
      android:paddingBottom="16dp" 
      android:paddingLeft="16dp" 
      android:paddingRight="16dp" 
      android:scrollbarStyle="outsideOverlay"/> 
    </android.support.v4.widget.SwipeRefreshLayout> 

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

Antwort

16

Es stellte sich heraus, dass dies Teil einer neuen Material Design Specification ist, die in Version 24 der Design Library eingeführt wurde.

https://material.google.com/patterns/navigation.html

Allerdings ist es möglich, den zusätzlichen Platz zu entfernen, indem Sie die folgende Eigenschaft Hinzufügen Widget-Symbolleiste.

app:contentInsetStartWithNavigation="0dp" 
+0

Dies sollte die richtige Antwort sein, arbeitete für mich auch !! :) – Aakash

+0

Funktioniert wie ein Charme. Ich danke dir sehr! –