0

I am trying to implement a Flexible space scrolling technique with a TextView attached to the bottom of the Toolbar. I've followed this, this and this questions. But my textview doesn't seem to scroll much up with the collapsing image. I want it to stick to the toolbar at all times.

Thanks.

This is what happens

enter image description here

Here is my layout file code.

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.myfirstapp.RecyclerFrag">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="300dp"
    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:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="25dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

        <ImageView
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/scenery"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            app:layout_collapseMode="parallax"/>


        <View
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:layout_gravity="bottom"
            android:background="@drawable/scrim"/>

        <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/ThemeOverlay.AppCompat.Light"/>
    </android.support.design.widget.CollapsingToolbarLayout>

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

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardBackgroundColor="#87b5ff"
    app:layout_anchor="@+id/header"
    app:layout_anchorGravity="bottom"
    android:layout_gravity="bottom"
    app:cardElevation="10dp"
    app:layout_collapseMode="pin">
    <TextView
        android:text="HHHHHHHHHHHHHHHH"
        android:gravity="center_horizontal|center_vertical"
        android:id="@+id/testv"
        android:background="#87b5ff"
        android:layout_width="match_parent"
        android:layout_height="51dp"
        app:layout_anchor="@+id/toolbar"
        app:layout_anchorGravity="bottom"
        android:layout_gravity="bottom"/>
</android.support.v7.widget.CardView>


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

</android.support.design.widget.CoordinatorLayout>
Navneet Krishna
  • 5,009
  • 5
  • 25
  • 44

0 Answers0