I am setting the collapsing toolbar layout. I have set the parallax mode for the relative layout below the toolbar.
But it dose not get fade when I scroll the toolbar up. I just shows the relative layout above the toolbar's title. It get's merged with the toolbar.
Have set all the modes still it's getting merged.
Layout :
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:id="@+id/appbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
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:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
<RelativeLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
app:layout_collapseMode="parallax"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
<TextView
android:id="@+id/eventName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Event Name"
android:textColor="#ffffff"
android:textSize="14sp"/>
<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/eventName"
android:layout_marginTop="10dp"
android:text="Date"
android:textColor="#ffffff"
android:textSize="14sp"/>
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/date"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="Time"
android:textColor="#ffffff"
android:textSize="14sp"/>
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:layout_below="@+id/textView6"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PLAN"
android:layout_centerHorizontal="true"
android:textAppearance="@android:style/TextAppearance.Large"
android:id="@+id/textView6"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="150dp"
android:layout_height="40dp"
style="?android:attr/borderlessButtonStyle"
android:text="Schedule"
android:id="@+id/schedule"
android:layout_gravity="center_horizontal"
android:background="@drawable/list_background"
android:layout_marginTop="20dp" />
<Button
android:layout_width="150dp"
android:layout_height="40dp"
style="?android:attr/borderlessButtonStyle"
android:text="Check List"
android:id="@+id/button4"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@drawable/list_background" />
<Button
android:layout_width="150dp"
android:layout_height="40dp"
android:text="Vendors"
style="?android:attr/borderlessButtonStyle"
android:id="@+id/button5"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@drawable/list_background" />
<Button
android:layout_width="150dp"
android:layout_height="40dp"
android:text="Invitee"
style="?android:attr/borderlessButtonStyle"
android:id="@+id/button6"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@drawable/list_background" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
looks like this after scrolling up :
What's wrong?
Please help Thank you..
Try to remove
enterAlways
from yourRelative Layout
.
Only use this.
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
For e.g You
Layout
ToolBar
Should be BelowRelative Layout
.
<RelativeLayout
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@drawable/header"
android:fitsSystemWindows="true"
android:scaleType="centerCrop">
<ImageView
android:id="@+id/imageViewPhoto"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
app:layout_collapseMode="parallax" />
<TextView
android:id="@+id/textViewName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_below="@+id/imageViewPhoto"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="TEXT"
android:textSize="16dp" />
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true"
android:gravity="top"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="20dp"
android:textStyle="bold" />
</android.support.v7.widget.Toolbar>