title: How to create a floating action button (FAB) in android, using AppCompat v21?
body: <p>I would like to create a floating action button (to add items to a listview), like google calendar, maintaining compatibility with pre-lollipop Android versions (before 5.0).</p>
  
  <p>I created this layout:</p>
  
  <p>Activity main_activity.xml:</p>
  
  <pre><code>&lt;LinearLayout ... &gt;
  
       &lt;include
           layout="@layout/toolbar"/&gt;
  
       &lt;RelativeLayout ... &gt;
  
       &lt;!-- My rest of the layout --&gt;
  
            &lt;!-- Floating action button --&gt;
            &lt;ImageButton style="@style/AppTheme"
                       android:layout_width="60dp"
                       android:layout_height="60dp"
                       android:text="New Button"
                       android:id="@+id/button"
                       android:src="@drawable/ic_fab"
                       android:background="@drawable/fab"
                       android:layout_alignParentBottom="true"
                       android:layout_alignParentRight="true"
                       android:layout_marginBottom="24dp"
                       android:layout_marginRight="24dp"/&gt;
  
       &lt;/RelativeLayout&gt;
  
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Drawable fab.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
         android:shape="oval"&gt;
      &lt;solid android:color="#ffa48bc0"/&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>Style styles.xml</p>
  
  <pre><code>&lt;resources&gt;
      &lt;style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;
          &lt;item name="colorPrimary"&gt;#ff1d79b1&lt;/item&gt;
          &lt;item name="colorPrimaryDark"&gt;#ff084d95&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>The result is similar, but there isn't the shading, a characteristic of material design:</p>
  
  <p>Calendar's floating action button:</p>
  
  <p><img src="https://i.stack.imgur.com/s9RmX.png" alt="Calendar&#39;s floating action button"></p>
  
  <p>My app's floating action button:</p>
  
  <p><img src="https://i.stack.imgur.com/zxOJL.png" alt="My app&#39;s floating action button"></p>
  
  <p>How can I add the shading to my button?</p>
  
  <p>I have already used the attribute elevation, but does not work</p>