title: Parallax Scrolling/Collapsable Toolbar in Android
body: <p>So here is some code from a udacity project for Material Design. It is supposed to show a collapsing toolbar that transforms from a photo with text to simple text. The udacity videos lead me to believe the code worked but when I downloaded the app to my phone, the toolbar did not collapse (the OS is android 6.0.1, v23). Is there something I could change to ensure the toolbar collapses?</p>
  
  <p>The code </p>
  
  <p>xml</p>
  
  <p></p>
  
  <pre><code>&lt;android.support.design.widget.AppBarLayout
      android:id="@+id/app_bar_layout"
      android:layout_width="match_parent"
      android:layout_height="192dp"
      android:background="?colorPrimary"&gt;
  
      &lt;android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:collapsedTitleTextAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"
          app:expandedTitleTextAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"
          app:expandedTitleMarginStart="72dp"
          app:contentScrim="?attr/colorPrimary"
          app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;
  
              &lt;ImageView
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  app:layout_collapseMode="parallax"
                  android:scaleType="centerCrop"
                  android:src="@drawable/eclairs" /&gt;
  
  
          &lt;android.support.v7.widget.Toolbar
              android:id="@+id/app_bar"
              android:layout_width="match_parent"
              android:layout_height="?actionBarSize"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
              app:navigationIcon="@drawable/arrow_left"
              app:contentInsetStart="72dp"
              app:layout_collapseMode="pin" /&gt;
  
  
      &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;ScrollView
      android:layout_width="match_parent"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
          android:layout_marginTop="16dp"
          android:textAppearance="@style/Base.TextAppearance.AppCompat.Body1"
          android:text="@string/cupcake_ipsum"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="16dp"
          android:layout_marginRight="16dp" /&gt;
  
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p></p>
  
  <p>JAVA</p>
  
  <pre><code>package com.example.android.dynamicsurfacesdemo;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.support.design.widget.CollapsingToolbarLayout;
  
  public class MainActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
      ((CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar_layout)).setTitle("Eclairs");
  
      }
  } 
  </code></pre>