AppBarLayout (wrap_content) не работает с CollapsingToolbarLayout (просмотр изображений внутри) - PullRequest
0 голосов
/ 16 марта 2019

Фиксированная высота AppBarLayout работает совершенно корректно и при изменении на wrap_content вызывает проблемы.

Когда я применяю содержимое обтекания, в нижней части AppbarLayout появляется дополнительное пространство. В приложении мне нужна сворачивающаяся панель инструментов, закрывающая строку состояния. Поэтому после добавления свойства android: fitsSystemWindows = "true" я вижу еще одну проблему. Выравнивание FloatingActionButton также не работает должным образом.

Screen Attached here

Код:

<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ui.events.ScrollingActivity">

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

    <net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:maxLines="3"
        app:titleEnabled="true">

        <ImageView
            android:id="@+id/iv_banner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:adjustViewBounds="true"
            android:src="@drawable/add_event_bg_gradient"
            app:contentScrim="@color/colorPrimary"
            app:layout_collapseMode="parallax"
            tools:ignore="contentDescription" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:adjustViewBounds="true"
            android:src="@drawable/grey_bg_gradient"
            app:contentScrim="@color/colorPrimary"
            app:layout_collapseMode="parallax"
            tools:ignore="contentDescription" />

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/fab_margin"
    app:layout_anchor="@id/app_bar"
    app:layout_anchorGravity="bottom|end"
    app:srcCompat="@drawable/ic_edit_vector"
    tools:ignore="VectorDrawableCompat" />

<include layout="@layout/Nested scrolling layout" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

Я не получаю клей там, где что-то пропустил. Когда я проверял несколько ссылок, это была проблема, доступная в библиотеках поддержки старых версий. Есть ли исправление, доступное для этого?

...