Coordinator. The contents of the layout are displayed behind the status bar.

I am creating a toolbar with a map fragment as part of this. The toolbar is fixed and opaque.

Whenever the contents of a view scroll up, a piece of the map moves with it, but it appears above the toolbar (and therefore between the status bar itself and the orange status background).

This is the resulting problem: MapFragment overrides the status bar

If I scroll a little more, the canvas gradually disappears, but it's too late.

Is there a way to not draw content when it goes beyond the toolbar? Or a way to make the status bar background paint before the contents of the AppBarLayout?

AppBarLayout ( ), MapFragment , , MapFragment .

<?xml version="1.0" encoding="utf-8"?>
<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/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/promotion_details_image_height"
        android:clickable="true"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/orange"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="?attr/actionBarSize">

            <fragment
                android:id="@+id/map"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="none"
                tools:context=".restaurants.stores.StoresFragment" />

            <ImageView
                android:id="@+id/minimizeBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/stores_details_minimize_margin"
                android:clickable="true"
                android:contentDescription="@null"
                android:paddingTop="@dimen/status_bar_height"
                android:src="@drawable/selector_map_minimize_btn"
                android:visibility="gone" />

            <include
                android:id="@+id/cardDetailsLayout"
                layout="@layout/store_card_small_detail"
                android:layout_width="match_parent"
                android:layout_height="@dimen/stores_details_card_height"
                android:layout_alignParentBottom="true"
                android:layout_margin="10dp"
                android:visibility="gone" />
        </RelativeLayout>

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

            <com.app.views.FontTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:singleLine="true"
                android:text="@string/store_toolbar_text"
                android:textColor="@color/white"
                android:textSize="@dimen/toolbar_text_size"
                app:font="@string/fontFlamaMedium" />
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>

: xml android: layout_behavior, RecyclerView, , , , .

+4
2

android:background="?attr/colorPrimary"

CollapsingToolbar

 app:contentScrim="?attr/colorPrimary"

ContentScrim , , .

0
0

Source: https://habr.com/ru/post/1622113/


All Articles