AppBarLayout / CollapsingToolbarLayout перекрывается нижней навигацией - PullRequest
0 голосов
/ 11 сентября 2018

У меня есть следующий макет активности:

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

    <data>

        <import type="com.aurelhubert.ahbottomnavigation.AHBottomNavigation" />

        <variable
            name="viewModel"
            type="[...]android.ui.MainViewModel" />
    </data>

    <RelativeLayout
        android:id="@+id/wrapper"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ui.MainActivity">

        <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/bottom_navigation" />

        <com.aurelhubert.ahbottomnavigation.AHBottomNavigation
            android:id="@+id/bottom_navigation"
            android:layout_width="match_parent"
            android:layout_height="@dimen/bottom_navigation_height"
            android:layout_alignParentBottom="true"
            app:accentColor="@color/bottomNavActive"
            app:defaultBackgroundColor="@{@color/bottomNavBg}"
            app:inactiveColor="@color/bottomNavInactive"
            app:titleState="@{AHBottomNavigation.TitleState.ALWAYS_SHOW}"
            app:useElevation="@{false}" />

        <FrameLayout
            android:id="@+id/floating_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"/>

    </RelativeLayout>

</layout>

И фрагмент, который отображается в FrameLayout:

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

    <data>
        <variable
            name="viewModel"
            type="[...]android.ui.home.jobs.JobsViewModel" />

        <variable
            name="navigationViewModel"
            type="[...]android.ui.NavigationViewModel" />
    </data>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appbar_layout"
            android:layout_width="match_parent"
            android:layout_height="@dimen/extended_toolbar_height"
            android:theme="@style/AppBarLayoutTheme">

            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:expandedTitleMarginBottom="@dimen/extended_toolbar_title_margin_bottom"
                app:expandedTitleMarginEnd="@dimen/content_indent_end"
                app:expandedTitleMarginStart="@dimen/content_indent_start"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <androidx.appcompat.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:title="@string/jobs_title" />

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

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

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:itemBinding="@{viewModel.itemBinding}"
            app:items="@{viewModel.items}"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>

Весь фрагмент должен отображаться над AHBottomNavigation следующим образом:

Желаемое состояние

Однако иногда при переключении вкладок или повороте экрана результат выглядит следующим образом (содержимое перекрывается нижней навигацией; больше прокручивать нельзя):

Нижнее меню, перекрывающее содержимое

Кажется, что корень проблемы как-то в CollapsingToolbarLayout, а не в AHBottomNavigation (не работает, даже если AHBottomNavigation заменяется чем-то другим).

У вас есть идеи, где может быть проблема? Спасибо за любые предложения.

...