trying to build an Android app with a collapsingtoolbarlayout and a view element that always sticks directly below the bottom of the toolbar.
I think I'm just messing up my organization within the whole appbarlayout, but I can't seem to figure out the right ordering.
Any help would be great! Thanks-
Here's my Activity xml
    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="244dp"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:collapsedTitleTextAppearance="@style/CollapsedTheme"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleGravity="center|bottom"
            app:expandedTitleMarginBottom="20dp"
            app:expandedTitleMarginEnd="20dp"
            app:expandedTitleMarginStart="20dp"
            app:expandedTitleTextAppearance="@style/ExpandedTheme"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:theme="@style/ToolbarColoredBackArrow">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="180dp"
                android:orientation="vertical">
            </LinearLayout>
            <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/AppTheme.PopupOverlay" />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
    <include layout="@layout/content_product" />
And I'm trying to add in
    <RelativeLayout
        android:layout_below="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@color/blue"/>
So that it always stays below the toolbar, but when the collapsingtoolbarlayout scrolls to the top of the screen, it stays sticking below it.
An AppBarLayout extends LinearLayout - just add your RelativeLayout below your CollapsingToolbarLayout and don't include any layout_scrollFlags.
<AppBarLayout>
  <CollapsingToolbarLayout />
  <RelativeLayout />
</AppBarLayout>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With