title: How to make RecyclerView inside CardView and CardView have it's size when it has low items
body: <p>I have a <code>RecyclerView</code> inside a <code>CardView</code> but i have problem that i have 2 buttons in bottom of the <code>RecyclerView</code> so i put them at the end of <code>RelativeLayout</code> and give them <code>parent_bottom</code> true so i can make them visible but that makes the <code>CardView</code> have the full screen whether the <code>RecyclerView</code> have items of not.</p>
  
  <h2>Xml code:</h2>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
  &lt;android.support.v7.widget.CardView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="12dp"
      app:cardElevation="8dp"&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/white"
          android:padding="8dp"&gt;
  
          &lt;TextView
              android:id="@+id/activeInspections"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text=" Your active inspections"
              android:textSize="18sp" /&gt;
  
          &lt;android.support.v7.widget.RecyclerView
              android:id="@+id/rvActiveInspections"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_above="@id/btnClear"
              android:layout_below="@+id/activeInspections"
              android:layout_marginTop="8dp" /&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="8dp"
              android:layout_alignParentBottom="true"
              android:layout_marginTop="8dp"
              android:id="@+id/btnClear"
              android:background="?selectableItemBackground"
              android:text="CLear" /&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentRight="true"
              android:layout_marginBottom="8dp"
              android:layout_marginTop="8dp"
              android:id="@+id/btnContinue"
              android:layout_alignParentBottom="true"
              android:background="?selectableItemBackground"
              android:text="Continue"
              android:textColor="@color/blue_normal" /&gt;
  
      &lt;/RelativeLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p></p>
  
  <p><a href="https://i.stack.imgur.com/42npM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/42npM.png" alt="Like this"></a> </p>
  
  <p>And when i tried another thing the code below to make them below the <code>RecyclerView</code> so it fixed in case and the other case like shown (Buttons at the bottom not shown)</p>
  
  <p>So how to fix this ? </p>
  
  <pre><code>&lt;RelativeLayout 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.v7.widget.CardView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="12dp"
      app:cardElevation="8dp"&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/white"
          android:padding="8dp"&gt;
  
          &lt;TextView
              android:id="@+id/activeInspections"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text=" Your active inspections"
              android:textSize="18sp" /&gt;
  
          &lt;android.support.v7.widget.RecyclerView
              android:id="@+id/rvActiveInspections"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@+id/activeInspections"
              android:layout_marginTop="8dp" /&gt;
  
          &lt;Button
              android:id="@+id/btnClear"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
  
              android:layout_below="@+id/rvActiveInspections"
              android:layout_marginBottom="8dp"
              android:layout_marginTop="8dp"
              android:background="?selectableItemBackground"
              android:text="CLear" /&gt;
  
          &lt;Button
              android:id="@+id/btnContinue"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentRight="true"
              android:layout_below="@+id/rvActiveInspections"
              android:layout_marginBottom="8dp"
              android:layout_marginTop="8dp"
  
              android:background="?selectableItemBackground"
              android:text="Continue"
              android:textColor="@color/blue_normal" /&gt;
  
      &lt;/RelativeLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p></p>
  
  <p><a href="https://i.stack.imgur.com/qEVo3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qEVo3.png" alt="Buttons at the bottom not shown"></a></p>
  
  <p>the target one is this and when items expands it fit only the screen and don't go out of it </p>
  
  <p><a href="https://i.stack.imgur.com/JD9Kd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JD9Kd.png" alt="enter image description here"></a></p>