material-components / material-components/material-components-android
[CollapsingToolbarLayout] Fragment navigateUp causes viewgroup with scrollflags reset its position.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
> also not fixed for me, i have a video for it.
>
>
> mylayout.xml
>
> xmlns:app="http://schemas.android.com/apk/res-auto"
> xmlns:tools="http://schemas.android.com/tools"
> android:layout_width="match_parent"
> android:layout_height="match_parent"
> android:fitsSystemWindows="false"
> tools:context=".activity.anime.fragment.detail.Fragment">
>
> android:id="@+id/fragment_detail_appbar"
> android:layout_height="wrap_content"
> android:layout_width="match_parent"
> android:fitsSystemWindows="true">
>
> android:id="@+id/fragment_detail_collapsing_toolbar"
> style="?attr/collapsingToolbarLayoutLargeStyle"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> app:layout_scrollFlags="scroll|exitUntilCollapsed"
> app:expandedTitleTextColor="@android:color/transparent">
>
> android:layout_width="match_parent"
> android:layout_height="match_parent"
> android:fitsSystemWindows="true"
> app:layout_collapseMode="pin">
>
> android:id="@+id/fragment_detail_thumbnail"
> android:layout_width="match_parent"
> android:layout_height="250dp"
> android:scaleType="centerCrop"
> android:background="?attr/colorSurfaceContainer"
> app:layout_constraintTop_toTopOf="parent"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintEnd_toEndOf="parent" />
>
> android:id="@+id/fragment_detail_cover_container"
> android:layout_width="180dp"
> android:layout_height="280dp"
> android:padding="8dp"
> android:layout_marginTop="?attr/collapsingToolbarLayoutMediumSize"
> android:layout_marginBottom="16dp"
> android:background="?attr/colorSurfaceContainerHighest"
> android:layout_gravity="center_horizontal"
> app:layout_constraintTop_toTopOf="parent"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintEnd_toEndOf="parent">
>
> android:id="@+id/fragment_detail_cover"
> android:layout_width="match_parent"
> android:layout_height="match_parent"
> android:scaleType="centerCrop" />
>
>
>
> android:id="@+id/fragment_detail_title"
> style="?attr/textAppearanceHeadlineMedium"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:paddingTop="@dimen/inner_spacing"
> android:paddingHorizontal="@dimen/inner_spacing"
> android:textAlignment="center"
> android:textStyle="bold"
> app:layout_constraintEnd_toEndOf="parent"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintTop_toBottomOf="@id/fragment_detail_cover_container"
> tools:text="Title" />
>
> android:id="@+id/fragment_detail_alternative_title"
> style="?attr/textAppearanceHeadlineSmall"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:paddingHorizontal="@dimen/inner_spacing"
> tools:text="Alternative Title"
> android:textAlignment="center"
> android:alpha="0.7"
> app:layout_constraintTop_toBottomOf="@id/fragment_detail_title"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintEnd_toEndOf="parent" />
>
>
> android:id="@+id/fragment_detail_toolbar"
> android:layout_width="match_parent"
> android:layout_height="?attr/actionBarSize"
> app:title="@string/detail_fragment_label"
> app:navigationIcon="@drawable/baseline_arrow_back_24"
> app:navigationIconTint="?attr/colorControlNormal"
> app:layout_collapseMode="pin" />
>
>
>
>
> android:id="@+id/fragment_detail_nested_scroll"
> android:layout_width="match_parent"
> android:layout_height="match_parent"
> android:fillViewport="true"
> android:fitsSystemWindows="false"
> app:layout_behavior="@string/appbar_scrolling_view_behavior">
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:paddingHorizontal="@dimen/inner_spacing"
> android:paddingTop="8dp"
> android:paddingBottom="?attr/actionBarSize"
> android:fitsSystemWindows="false">
>
> android:id="@+id/fragment_detail_progressbar"
> style="?android:attr/progressBarStyle"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> android:layout_margin="@dimen/inner_spacing"
> android:indeterminate="true"
> android:layout_gravity="center"
> android:visibility="visible"
> tools:visibility="gone"
> app:layout_constraintTop_toTopOf="parent"
> app:layout_constraintEnd_toEndOf="parent"
> app:layout_constraintStart_toStartOf="parent" />
>
> android:id="@+id/fragment_detail_content"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:visibility="gone"
> tools:visibility="visible"
> app:layout_constraintTop_toTopOf="parent"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintEnd_toEndOf="parent"
> app:layout_constraintBottom_toBottomOf="parent">
>
> android:id="@+id/fragment_detail_synopsis_title"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="?attr/textAppearanceTitleMedium"
> android:text="@string/common_synopsis"
> app:layout_constraintTop_toTopOf="parent"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintEnd_toEndOf="parent" />
>
> android:id="@+id/fragment_detail_synopsis_body"
> style="?attr/textAppearanceBodyMedium"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:paddingVertical="@dimen/inner_spacing"
> android:alpha="0.7"
> android:textIsSelectable="true"
> tools:text="@string/lorem_ipsum"
> app:layout_constraintTop_toBottomOf="@id/fragment_detail_synopsis_title"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintEnd_toEndOf="parent" />
>
> android:id="@+id/fragment_detail_ads_banner_1"
> android:layout_width="0dp"
> android:layout_height="60dp"
> android:orientation="vertical"
> android:gravity="center_horizontal|center_vertical"
> app:layout_constraintTop_toBottomOf="@id/fragment_detail_synopsis_body"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintEnd_toEndOf="parent" />
>
> android:id="@+id/fragment_detail_additional_info_title"
> style="?attr/textAppearanceTitleMedium"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:layout_marginVertical="@dimen/inner_spacing"
> android:text="@string/common_additional_info"
> app:layout_constraintTop_toBottomOf="@id/fragment_detail_ads_banner_1"
> app:layout_constraintStart_toStartOf="parent"
> app:layout_constraintEnd_toEndOf="parent" />
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:layout_marginTop="@dimen/inner_spacing"
> android:paddingBottom="@dimen/inner_spacing"
> android:orientation="vertical"
> android:divider="@drawable/divider_space"
> android:showDividers="middle"
> app:layout_constraintTop_toBottomOf="@id/fragment_detail_additional_info_title"
> app:layout_constraintEnd_toEndOf="parent"
> app:layout_constraintStart_toStartOf="parent">
>
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelLarge"
> android:text="@string/common_status"
> tools:text="Status" />
>
> android:id="@+id/fragment_detail_status"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelMedium"
> tools:text="Completed" />
>
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelLarge"
> android:text="@string/common_studio"
> tools:text="Status" />
>
> android:id="@+id/fragment_detail_studios"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> app:singleLine="false"
> app:chipSpacingHorizontal="8dp"
> app:chipSpacingVertical="4dp" />
>
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelLarge"
> android:text="@string/common_release"
> tools:text="Status" />
>
> android:id="@+id/fragment_detail_release"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelMedium"
> tools:text="Jul 25, 2025" />
>
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelLarge"
> android:text="@string/common_season"
> tools:text="Status" />
>
> android:id="@+id/fragment_detail_season"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelMedium"
> android:textColor="?attr/colorPrimary"
> tools:text="Summer 2025" />
>
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelLarge"
> android:text="@string/common_type"
> tools:text="Tipe" />
>
> android:id="@+id/fragment_detail_type"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelMedium"
> tools:text="OVA" />
>
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelLarge"
> android:text="@string/common_censor"
> tools:text="Sensor" />
>
> android:id="@+id/fragment_detail_censor"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelMedium"
> tools:text="Uncensored" />
>
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelLarge"
> android:text="@string/common_added"
> tools:text="Ditambahkan" />
>
> android:id="@+id/fragment_detail_created"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelMedium"
> tools:text="Agustus 9, 2025" />
>
>
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelLarge"
> android:text="@string/common_updated_on"
> tools:text="Diperbarui" />
>
> android:id="@+id/fragment_detail_updated"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> style="@style/TextAppearance.KaitoAni.LabelMedium"
> tools:text="Agustus 9, 2025" />
>
> android:id="@+id/fragment_detail_genres"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> app:singleLine="false"
> app:chipSpacingHorizontal="8dp"
> app:chipSpacingVertical="4dp" />
>
>
>
>
> android:layout_width="match_parent"
> android:layout_height="0dp"
> app:layout_constraintTop_toBottomOf="@id/fragment_detail_content" />
>
>
>
>
>
> android:id="@+id/fragment_detail_menu"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:layout_gravity="bottom"
> app:hideOnScroll="true"
> app:layout_behavior="com.google.android.material.bottomappbar.BottomAppBar$Behavior"
> app:menu="@menu/menu_detail" />
>
> android:id="@+id/fragment_detail_show_episodes"
> style="@style/Widget.Material3.ExtendedFloatingActionButton.Primary"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> android:text="@string/common_watch"
> app:layout_anchor="@id/fragment_detail_menu"
> app:icon="@drawable/baseline_playlist_play_24" />
>
>
>
>
> NSFW WARNING!!!
>
>
> Video demonstration:
>
>
_Originally posted by @BanDroid in [#1019](https://github.com/material-components/material-components-android/issues/1019#issuecomment-3239411049)_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided mylayout.xml and the Fragment context, then reproduce navigation-up with the AppBarLayout, CollapsingToolbarLayout, and NestedScrollView configuration shown. Trace the scroll position before and after Fragment navigateUp; done means the view group retains its position instead of resetting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100