0

搜索底部有空白。請檢查屏幕截圖。對不起我的英語不好。我提供了截圖以便更好地理解。如何刪除摺疊工具欄的底部空白處?

Screenshot 1

Screenshot 2

幫我解決這個問題。

主要活動XML

<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.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#ffe5e5e5" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      > 

      <include layout="@layout/card_layout" /> 

      <include layout="@layout/card_layout" /> 

      <include layout="@layout/card_layout" /> 

     </LinearLayout> 


    </android.support.v4.widget.NestedScrollView> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="250dp" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:minHeight="?attr/actionBarSize" 
      android:elevation="0dp" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="25dp" 
       android:layout_marginLeft="20dp" 
       android:layout_marginTop="20dp" 
       android:orientation="horizontal"> 

       <ImageView 
        android:layout_width="30dp" 
        android:layout_height="25dp" 
        android:background="@drawable/ic_menu" /> 

       <TextView 
        android:layout_width="80dp" 
        android:layout_height="25dp" 
        android:layout_marginLeft="0dp" 
        android:gravity="center" 
        android:text="FlipKart" 
        android:textColor="@android:color/white" 
        android:textStyle="bold" /> 

       <RelativeLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"> 

        <ImageView 
         android:id="@+id/imageviewCircle" 
         android:layout_width="10dp" 
         android:layout_height="10dp" 
         android:layout_gravity="end" 

         android:layout_marginLeft="100dp" 
         android:background="@drawable/circle" /> 

        <ImageView 
         android:id="@+id/imageviewBell" 
         android:layout_width="25dp" 
         android:layout_height="wrap_content" 
         android:layout_gravity="end" 
         android:layout_marginLeft="100dp" 
         android:background="@drawable/ic_bell" /> 
       </RelativeLayout> 

       <ImageView 
        android:layout_width="25dp" 
        android:layout_height="wrap_content" 
        android:layout_gravity="end" 
        android:layout_marginLeft="10dp" 
        android:background="@drawable/ic_cart" /> 

      </LinearLayout> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="40dp" 
       android:layout_marginLeft="20dp" 
       android:layout_marginRight="20dp" 
       android:layout_marginTop="80dp" 
       android:background="@drawable/rounded_edittext" 

       android:elevation="0dp" 
       app:layout_collapseMode="parallax" 
       app:layout_scrollFlags="scroll|enterAlways"> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="25dp" 

        android:orientation="horizontal" 
        app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

        <ImageView 
         android:id="@+id/imageviewSearch" 
         android:layout_width="25dp" 
         android:layout_height="25dp" 
         android:background="@drawable/ic_magnify" /> 

        <TextView 
         android:id="@+id/textviewSearch" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="30dp" 
         android:layout_marginTop="3dp" 
         android:cursorVisible="true" 
         android:editable="true" 
         android:elevation="0dp" 
         android:hint="Search for products,Brands " 
         android:textColorHint="@android:color/darker_gray" /> 
       </RelativeLayout> 
      </android.support.v7.widget.Toolbar> 


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

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

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

大家好。 我已經提供了我的XML文件的片段。由於我是noob,因此我要求StackOverflow部隊尋求幫助。

非常感謝您的幫助。

回答

0
<android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="250dp" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 

你硬編碼的AppBarLayout的高度,所以很明顯它永遠是250dp每次。調整該值以獲得正確的height

嘗試使用包裝內容都CollapsingToolbarLayout和AppBarLayout,如果它不工作,然後嘗試使用120dp到150dp爲AppBarLayout和match_parent值CollapsingToolbar