簡體   English   中英

如何刪除折疊工具欄的底部空白?

[英]how to remove bottom Whitespace of Collapsing toolbar?

搜索底部有空白。請檢查屏幕截圖。 對不起我的英語不好。 我提供了屏幕截圖以便於更好地理解。

屏幕截圖1

屏幕截圖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文件的片段。 由於我是菜鳥,因此我向StackOverflow部隊尋求幫助。

非常感謝您的幫助。

<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都使用換行內容,如果不起作用,請嘗試對AppBarLayout使用120dp至150dp的值,對CollapsingToolbar使用match_parent

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM