title: Android: Toolbar elevation / Shadow
body: <p>I would like to know why this toolbar cast a shadow only if NestedScrollView is there (I've got this example from the internet)</p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout
      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="match_parent"&gt;
  
      &lt;android.support.v4.widget.NestedScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
  
          &lt;!-- Your scrolling content --&gt;
  
      &lt;/android.support.v4.widget.NestedScrollView&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_height="wrap_content"
          android:layout_width="match_parent"&gt;
  
          &lt;android.support.v7.widget.Toolbar
              xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:local="http://schemas.android.com/apk/res-auto"
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:minHeight="?attr/actionBarSize"
              android:background="?attr/colorPrimary"
              local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
              local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
              /&gt;
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>This toolbar (without the NestedScrollView) don't cast any shadow:</p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout
      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="match_parent"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_height="wrap_content"
          android:layout_width="match_parent"&gt;
  
          &lt;android.support.v7.widget.Toolbar
              xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:local="http://schemas.android.com/apk/res-auto"
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:minHeight="?attr/actionBarSize"
              android:background="?attr/colorPrimary"
              local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
              local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
              /&gt;
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>I can post pictures, if needed, but I have no clue why this happen.
  This is what I've tried so far:</p>
  
  <ul>
  <li>Setting clipToPadding="false" on the parent Linear Layout</li>
  <li>Manually set elevation (my device is not Pre-Lollipop)</li>
  <li>Seting outlineProvider="bounds" on the view</li>
  <li>Setting android:hardwareAccelerated="true" on the AndroidManifest.xml</li>
  </ul>
  
  <p>Edit: I've solved it by using the  tag. Check my answer with the code.</p>