Solution 1 :
I think you are missing an actual toolbar inside the collapsing toolbar.
try adding a toolbar after the linear layout’s closing tag.
example:
<androidx.appcompat.widget.Toolbar
android_id="@+id/toolbar"
android_layout_width="match_parent"
android_layout_height="?attr/actionBarSize"
android_background="@color/colorPrimaryLight"
android_theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
app_layout_collapseMode="pin"
app_title="Toolbar title" />
and another thing I noticed, you AppBarLayout has android:fitsSystemWindows="true"
so check that as well.
Problem :
I have the following layout that has a collapsing toolbar with a LinearLayout inside –
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_app="http://schemas.android.com/apk/res-auto"
xmlns_tools="http://schemas.android.com/tools">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android_layout_width="match_parent"
android_layout_height="match_parent"
android_orientation="vertical"
tools_context=".application_flow.group.GroupOverviewFragment">
<com.google.android.material.appbar.AppBarLayout
android_layout_width="match_parent"
android_layout_height="200dp"
android_elevation="10dp"
android_fitsSystemWindows="true"
android_stateListAnimator="@animator/show_toolbar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android_layout_width="match_parent"
android_layout_height="match_parent"
app_collapsedTitleGravity="center"
app_contentScrim="@color/colorPrimary"
app_expandedTitleGravity="top"
app_layout_scrollFlags="scroll|exitUntilCollapsed"
app_title="Lohamei Galipoly 38"
app_titleEnabled="false"
app_toolbarId="@id/group_tasks_toolbar">
<LinearLayout
android_layout_width="match_parent"
android_layout_height="match_parent"
android_layout_marginStart="14dp"
android_layout_marginEnd="14dp"
android_orientation="vertical"
app_layout_collapseMode="parallax"
app_layout_collapseParallaxMultiplier="0.6">
<androidx.appcompat.widget.Toolbar
android_id="@+id/group_tasks_toolbar"
android_layout_width="match_parent"
android_layout_height="?attr/actionBarSize"
app_contentInsetStartWithNavigation="0dp"
app_layout_collapseMode="pin"
app_navigationIcon="@drawable/left_arrow_white"
app_titleTextColor="@color/white" />
<Space
android_layout_width="match_parent"
android_layout_height="0dp"
android_layout_weight="1" />
<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_gravity="center"
android_layout_marginBottom="30dp"
android_textColor="@color/white"
android_textSize="18sp"
tools_text="Total group tasks: 8" />
<com.google.android.material.tabs.TabLayout
android_id="@+id/group_tasks_tab_layout"
android_layout_width="match_parent"
android_layout_height="wrap_content"
app_tabIndicatorColor="@color/white"
app_tabMode="fixed"
app_tabSelectedTextColor="@color/white" />
</LinearLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager2.widget.ViewPager2
android_id="@+id/group_tasks_viewpager"
android_layout_width="match_parent"
android_layout_height="wrap_content"
app_layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
For some reason it does not collapse the entire content of the LinearLayout like it should and it is being left fixed in place.
This error seemed to start happening after I switched to work with the LinearLayout inside my CollapsingToolbarLayout
What is it that I am missing?
Comments
Comment posted by ʍѳђઽ૯ท
It’s already have a