Макет AppBar вызывает странное поведение прокрутки, когда он свернут программно - PullRequest
0 голосов
/ 18 июня 2019

Мой макет AppBar имеет TabLayout. Компоновка вкладки связана с видоискателем, в котором есть фрагменты с рециркуляцией. Я устанавливаю appBarLayout.setExpanded (false) нажатием кнопки.

При запуске этого метода appBar успешно сворачивается, и tabLayout в большинстве случаев располагается чуть ниже панели инструментов, но иногда он прокручивается и заканчивается либо полностью раскрытым, либо становится видимой некоторая часть appBar. В чем может быть причина этого странного свитка? Пожалуйста, помогите

Вот файл макета.

<android.support.design.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/parentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Light">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapseToolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleTextAppearance="@style/TextAppearance.AppCompat.Title"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="none">

            <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="200dp">

                <ImageView
                        android:id="@+id/iv_hero_image"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:fitsSystemWindows="true"
                        android:foreground="@drawable/dark_gradient"
                        android:scaleType="fitXY"/>

            </FrameLayout>

            <include layout="@layout/info_lyt"/>



            <android.support.v7.widget.AppCompatImageView
                    android:id="@+id/iv_logo"
                    android:layout_width="@dimen/dimen_65dp"
                    android:layout_height="@dimen/dimen_65dp"
                    android:layout_gravity="start"
                    android:layout_marginLeft="@dimen/dimen_16dp"
                    android:layout_marginTop="@dimen/dimen_150dp"
                    tools:src="@drawable/promo_icon"
                    tools:srcCompat="@tools:sample/avatars"/>

        </FrameLayout>


        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ToolBarStyle">

            <TextView
                android:id="@+id/toolbarTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

        </android.support.v7.widget.Toolbar>

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

    <android.support.design.widget.TabLayout
        android:layout_width="match_parent"
        android:layout_height="48dp"/>

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

<android.support.v4.view.ViewPager
    android:id="@+id/vpDetail"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

...