title: AppBarLayout cannot be cast to android.support.design.widget.CollapsingToolbarLayout
body: <p>I am getting this error:</p>
  
  <pre><code>Caused by: java.lang.ClassCastException: 
  android.support.design.widget.AppBarLayout cannot be cast to 
  android.support.design.widget.CollapsingToolbarLayout
  </code></pre>
  
  <p>This is my xml file:</p>
  
  <pre><code>&lt;android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="200dp"
      android:id="@+id/collapsing"
      android:fitsSystemWindows="true"
      app:layout_scrollFlags="scroll|exitUntilCollapsed"
      app:contentScrim="#0e0d0e"&gt;
  
      &lt;android.support.design.widget.CollapsingToolbarLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:theme="@style/AppTheme.NoActionBar"
          android:fitsSystemWindows="true"
          android:id="@+id/app_bar_layout"&gt;
  
          &lt;ImageView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:contentDescription="@null"
              app:layout_collapseMode="parallax"
              android:id="@+id/img_food"
              android:scaleType="centerCrop" /&gt;
          &lt;android.support.v7.widget.Toolbar
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
              app:layout_collapseMode="parallax"
              android:id="@+id/toolbar"
              app:title="Food Name"&gt;
  
          &lt;/android.support.v7.widget.Toolbar&gt;
      &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
  &lt;/android.support.design.widget.AppBarLayout&gt;
  </code></pre>
  
  <p>What is causing my error? I am redirected to this line </p>
  
  <pre><code>collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing);
  </code></pre>
  
  <p>in my activity file.</p>
  
  <p>I am using Android Studio 3.0.1.</p>
  
  <p>Thank you!</p>