Skip to content

[CollapsingToolbarLayout] Fragment navigateUp causes viewgroup with scrollflags reset its position. #4912

@BanDroid

Description

@BanDroid

also not fixed for me, i have a video for it.

mylayout.xml


<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/fragment_detail_appbar"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true">

    <com.google.android.material.appbar.CollapsingToolbarLayout
        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">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:layout_collapseMode="pin">

            <ImageView
                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" />

            <LinearLayout
                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">

                <ImageView
                    android:id="@+id/fragment_detail_cover"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop" />

            </LinearLayout>

            <com.google.android.material.textview.MaterialTextView
                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" />

            <com.google.android.material.textview.MaterialTextView
                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" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <com.google.android.material.appbar.MaterialToolbar
            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" />

    </com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>

<androidx.core.widget.NestedScrollView
    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">

    <androidx.constraintlayout.widget.ConstraintLayout
        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">

        <androidx.core.widget.ContentLoadingProgressBar
            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" />

        <androidx.constraintlayout.widget.ConstraintLayout
            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">

            <com.google.android.material.textview.MaterialTextView
                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" />

            <com.google.android.material.textview.MaterialTextView
                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" />

            <LinearLayout
                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" />

            <com.google.android.material.textview.MaterialTextView
                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" />

            <LinearLayout
                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">

                <!-- Status -->
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelLarge"
                    android:text="@string/common_status"
                    tools:text="Status" />

                <TextView
                    android:id="@+id/fragment_detail_status"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelMedium"
                    tools:text="Completed" />

                <!-- Studio -->
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelLarge"
                    android:text="@string/common_studio"
                    tools:text="Status" />

                <com.google.android.material.chip.ChipGroup
                    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" />

                <!-- Rilis -->
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelLarge"
                    android:text="@string/common_release"
                    tools:text="Status" />

                <TextView
                    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" />

                <!-- Musim -->
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelLarge"
                    android:text="@string/common_season"
                    tools:text="Status" />

                <TextView
                    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" />

                <!-- Tipe -->
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelLarge"
                    android:text="@string/common_type"
                    tools:text="Tipe" />

                <TextView
                    android:id="@+id/fragment_detail_type"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelMedium"
                    tools:text="OVA" />

                <!-- Censor -->
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelLarge"
                    android:text="@string/common_censor"
                    tools:text="Sensor" />

                <TextView
                    android:id="@+id/fragment_detail_censor"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelMedium"
                    tools:text="Uncensored" />

                <!-- Created -->
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelLarge"
                    android:text="@string/common_added"
                    tools:text="Ditambahkan" />

                <TextView
                    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" />

                <!-- Updated -->
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/TextAppearance.KaitoAni.LabelLarge"
                    android:text="@string/common_updated_on"
                    tools:text="Diperbarui" />

                <TextView
                    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" />

                <com.google.android.material.chip.ChipGroup
                    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" />
            </LinearLayout>

        </androidx.constraintlayout.widget.ConstraintLayout>

        <org.kaitoani.widget.SystemBarSpacer
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintTop_toBottomOf="@id/fragment_detail_content" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.core.widget.NestedScrollView>

<com.google.android.material.bottomappbar.BottomAppBar
    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" />

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
    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" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

NSFW WARNING!!!

Video demonstration:
Screen_recording_20250830_235815.mp4

Originally posted by @BanDroid in #1019

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions