gpt4 book ai didi

android - 折叠工具栏标题和主页/向上按钮之间的额外空间

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:21:57 27 4
gpt4 key购买 nike

我正在尝试将折叠工具栏与主页/向上按钮一起使用。工具栏折叠后,箭头和标题文本之间有一个额外的空间,我想去掉它。我附上了两张带有和不带布局边界的图片来说明我的观点。

我搜索了 StackOverflow 和所有地方并尝试了android:contentInsetStart="0dp"徒劳无功。

enter image description here

enter image description here

这是我的布局 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: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>

最佳答案

事实证明,这是 Design 库 24 版中引入的新 Material Design 规范的一部分。

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

但是,可以通过向工具栏小部件添加以下属性来删除多余的空间。

app:contentInsetStartWithNavigation="0dp"

关于android - 折叠工具栏标题和主页/向上按钮之间的额外空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38175505/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com