title: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.support.v7.widget.Toolbar
body: <p>I was trying to add a shadow to the toolbar following this example over here
  <a href="https://stackoverflow.com/a/26904102/4273056">https://stackoverflow.com/a/26904102/4273056</a></p>
  
  <p>My toolbar in activity</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  }
  </code></pre>
  
  <p>This is the xml file where I added the toolbar</p>
  
  <pre><code>&lt;LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="top"
  android:orientation="vertical"
  xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
  &lt;android.support.v7.widget.Toolbar            
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@color/primaryColor"
  android:paddingTop="@dimen/app_bar_top_padding"
  app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
  app:theme="@style/MyCustomToolBarTheme"&gt;
  
  &lt;/android.support.v7.widget.Toolbar&gt;
  &lt;FrameLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;!-- **** Place Your Content Here **** --&gt;
  
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="5dp"
          android:background="@drawable/shadow" /&gt;
  &lt;/FrameLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I get this in the logcat
  java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.support.v7.widget.Toolbar</p>
  
  <p>How can I get rid of this error?</p>