R
R
razer892015-12-14 22:17:36
Android
razer89, 2015-12-14 22:17:36

CoordinatorLayout and fitsSystemWindows?

Good evening!
The task is to display a photo under the status bar and toolbar. For scrolling, I use CoordinatorLayout and a custom Behavior, in which some transformation will be implemented in the future. In the video, the blue bar is "sticky" to the AppBarLayout using attributes:

app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom"

Here is the whole layout:
<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

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

            <FrameLayout
                android:id="@+id/main_frame"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                android:orientation="vertical"
                app:layout_collapseMode="parallax">

                <com.example.DynamicRelativeLayout
                    android:id="@+id/dynamic_layout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:id="@+id/logo"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:scaleType="centerCrop" />
                </com.example.DynamicRelativeLayout>
            </FrameLayout>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.example.ui.ExpandableLayout
                android:id="@+id/expandable_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:el_contentLayout="@layout/order_details_content"
                app:el_headerLayout="@layout/empty_layout" />
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

    <include
        android:id="@+id/details_header"
        layout="@layout/order_details_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom"
        app:layout_behavior="com.example.OrderHeaderBehavior" />

    <include
        android:id="@+id/toolbar"
        layout="@layout/transparent_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize" />

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

DynamicRelativeLayout - a regular RelativeLayout with an overridden onMeasure method , adjusts its height to a 16:9 ratio.
ExpandableLayout - expandable layout from here . As a header, I fed him a "dummy" - @layout/empty_layout , because for my purposes, I need the header to be in a CoordinatorLayout . Actually, this is what id/details_header is for, when clicked, ExpandableLayout expands .
As you can see in the video , when scrolling, the picture is covered by the details_header layout, but at some point (to be precise, at the moment the AppBarLayout "sticks"to the top) for some reason it comes to the fore. Help advice, who faced this.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question