tzegian
tzegian

Reputation: 589

Android CollapsingToolbar not collapsing in some cases

I have a problem with CollapsingToolbarLayout not collapsing in some cases only. The report came only from one user with a Samsung Galaxy A53. We tried reproducing it in other Samsung & Xiaomi phones & Android Studio Emulators with no success.

My XML layout is this:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:fitsSystemWindows="false">

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background_rounded_bottom"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:orientation="vertical"
    app:liftOnScroll="true">

    <com.google.android.material.appbar.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipChildren="false"
        android:clipToPadding="false"
        app:collapsedTitleGravity="start|center_vertical"
        app:collapsedTitleTextAppearance="@style/TextAppearance.WeatherXM.CollapsedToolbar.Title"
        app:collapsedTitleTextColor="@color/colorOnSurface"
        app:expandedTitleTextColor="@color/transparent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
        app:titleCollapseMode="fade"
        app:titleEnabled="true">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:paddingHorizontal="@dimen/padding_normal"
            android:paddingTop="?actionBarSize"
            app:layout_scrollFlags="scroll">

            ...
            ...
            ...
            ...

        </androidx.constraintlayout.widget.ConstraintLayout>

        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?actionBarSize"
            android:background="@color/colorSurface"
            app:layout_collapseMode="pin"
            app:menu="@menu/device_details_menu"
            app:navigationIcon="@drawable/ic_back" />

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

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/navigatorGroup"
        style="@style/Widget.WeatherXM.TabLayout.Navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/margin_small"
        app:layout_scrollFlags="snap" />

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

<androidx.viewpager2.widget.ViewPager2
    android:id="@+id/viewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"    app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

Any ideas what might have gone wrong on that specific user?

Upvotes: 0

Views: 32

Answers (0)

Related Questions