title: CardView shadow not rendered when converted to bitmap
body: <p><strong>THE PROBLEM</strong></p>
  
  <p>I'm try to save a view group (which has a <code>CardView</code> as one of its childern) as a PNG file. To achieve this, </p>
  
  <ol>
  <li>I inflate the view group and populate the views with required information</li>
  <li>Load an image to an image view via <a href="https://github.com/bumptech/glide" rel="noreferrer">Glide</a></li>
  <li>Add a <code>ViewTreeObserver.OnGlobalLayoutListener</code> to the <code>ViewTreeObserver</code> of the image view and pass the entire (parent) view that is going to be shared to a method that converts the view to a bitmap <em>when</em> image view's bottom is greater than zero (image view's height attribute is set to <code>wrap_content</code>, thus its bottom will be zero until image is loaded).</li>
  </ol>
  
  <p>By doing this, I'm able to convert the view to a bitmap, however, with one caveat: the <code>CardView</code>'s show is not rendered on the bitmap.</p>
  
  <p><strong>FAILED ATTEMPTS</strong></p>
  
  <p>So far I've tried:</p>
  
  <ol>
  <li>Switching between <code>layerType</code> attribute from "software" to "hardware".</li>
  <li>Setting on and off <code>cardUseCompatPadding</code> attribute of the <code>CardView</code>.</li>
  <li>Tried setting the image drawable without using Glide.</li>
  <li>Tried without loading an image drawable at all.</li>
  </ol>
  
  <p><strong>THE CODE</strong></p>
  
  <p>Here are code snippets that might help you guys identify the problem:</p>
  
  <p>The method used to convert a view to a bitmap</p>
  
  <pre><code>public static Bitmap getBitmapFromView(View view) {
      //Define a bitmap with the same size as the view
      Bitmap b = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
      //Bind a canvas to it
      Canvas canvas = new Canvas(b);
      //Get the view's background
      Drawable bgDrawable = view.getBackground();
      if (bgDrawable != null)
          //has background drawable, then draw it on the canvas
          bgDrawable.draw(canvas);
      else
          //does not have background drawable, then draw white background on the canvas
          canvas.drawColor(Color.WHITE);
      // draw the view on the canvas
      view.draw(canvas);
      //return the bitmap
      return b;
  }
  </code></pre>
  
  <p>XML layout file of the view that's being inflated and passed to the <code>getBitmapFromView()</code> above.</p>
  
  <pre><code>&lt;LinearLayout 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"
      android:orientation="vertical"
      android:paddingBottom="16dp"&gt;
  
      &lt;com.devspark.robototextview.widget.RobotoTextView
          android:id="@+id/title"
          style="@style/text_subhead"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="top"
          android:layout_marginBottom="@dimen/lessons_horizontal_margin_narrow"
          android:layout_marginLeft="@dimen/lessons_horizontal_margin_narrow"
          android:layout_marginRight="@dimen/lessons_horizontal_margin_narrow"
          android:layout_marginTop="@dimen/lessons_horizontal_margin_narrow"
          android:gravity="left"
          app:typeface="roboto_medium" /&gt;
  
      &lt;com.devspark.robototextview.widget.RobotoTextView
          android:id="@+id/text"
          style="@style/text_subhead"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginLeft="@dimen/lessons_horizontal_margin_narrow"
          android:layout_marginRight="@dimen/lessons_horizontal_margin_narrow"
          android:gravity="left"
          android:textColor="@color/text"
          app:typeface="roboto_regular" /&gt;
  
      &lt;android.support.v7.widget.CardView
          android:id="@+id/image_container"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_margin="@dimen/lessons_horizontal_margin_narrow"
          app:cardCornerRadius="@dimen/lessons_image_card_corner_radius"
          app:cardElevation="3dp"
          app:cardPreventCornerOverlap="false"
          app:cardUseCompatPadding="true"&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"&gt;
  
              &lt;com.makeramen.roundedimageview.RoundedImageView
                  android:id="@+id/image"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:contentDescription="@null"
                  app:riv_corner_radius_top_left="@dimen/lessons_image_card_corner_radius"
                  app:riv_corner_radius_top_right="@dimen/lessons_image_card_corner_radius" /&gt;
  
              &lt;com.devspark.robototextview.widget.RobotoTextView
                  android:id="@+id/caption"
                  style="@style/text_caption"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_margin="@dimen/lessons_image_card_caption_margin"
                  android:gravity="left"
                  app:typeface="roboto_condensed_regular" /&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/android.support.v7.widget.CardView&gt;
  
      &lt;!-- Some other views that aren't particularly interesting --&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>