gpt4 book ai didi

android - fragment 内的折叠工具栏布局在顶部留下空白

转载 作者:太空宇宙 更新时间:2023-11-03 13:48:00 25 4
gpt4 key购买 nike

我正在做一个项目,每当我尝试在 fragment 内添加折叠布局时,它都会在顶部留下空白区域 enter image description here

如下图所示,在 Activity 内部使用的工具栏一旦我添加折叠工具栏,它就会留下橙色上方的空白区域。

这是我的 Fragment 代码。

<?xml version="1.0" encoding="utf-8"?>

xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">


<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_gravity="fill_vertical"
android:layout_height="220dp"
app:contentScrim="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:statusBarScrim="@android:color/transparent"
>

<ImageView
android:layout_width="match_parent"
android:layout_height="220dp"
android:background="@color/review_orange"
android:src="@drawable/icon_collabartion" />



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


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


<android.support.v7.widget.RecyclerView
android:layout_marginTop="10dp"
android:id="@+id/rcv_showTimings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>







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

最佳答案

我知道这是一个老问题,但让我提示一下!

您有一项主要 Activity 。

你有 10 个 fragment 。

您的主要 Activity 可以托管 10 个 fragment 。

正如 Kris 所说,您需要将工具栏保留在那里,您不应该移动它,然后在创建您的 fragment 之后,在该 fragment 中设置一个监听器,该监听器调用 Activity 中的剩余初始化序列,如果没有创建 fragment 。 (Drawer+NavigationView(来自 Activity )和包含工具栏的 CollapsingLayout(在您的 fragment 中)。

关于android - fragment 内的折叠工具栏布局在顶部留下空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38797339/

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