title: fill rest of the space using linearlayout
body: <p>I have a <a href="https://github.com/SeakyLuo/RandomMenu/blob/master/app/src/main/res/layout/fragment_food_card.xml" rel="nofollow noreferrer">FoodCardFragment</a> that has a <code>CardView</code> at the bottom. I want the <code>CardView</code> to have a height of at least 120dp and fill the rest of the space (so I set its <code>layout_weight</code> to 1).</p>
  
  <p>The <code>FoodCardFragment</code> is put in the <a href="https://github.com/SeakyLuo/RandomMenu/blob/master/app/src/main/res/layout/fragment_random.xml" rel="nofollow noreferrer">RandomFragment</a> (the first tab of <a href="https://github.com/SeakyLuo/RandomMenu/blob/master/app/src/main/res/layout/activity_main.xml" rel="nofollow noreferrer">MainAcitivity</a>), and also has its <code>layout_weight</code> set to 1 as I want it to fill the rest of the space.</p>
  
  <p>However, as you can tell from the image I posted below, the yellow <code>CardView</code> I mentioned above doesn't fill the rest of the space. How can I achieve my goal?</p>
  
  <p><a href="https://i.stack.imgur.com/WBIY1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WBIY1.jpg" alt="enter image description here"></a></p>
  
  <p>In case the links won't work:</p>
  
  <p>Code for FoodCardFragment:</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:padding="20dp"
      android:background="@android:color/white"&gt;
  
      &lt;android.support.v7.widget.CardView
          android:id="@+id/food_card"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:elevation="2dp"&gt;
  
          &lt;android.support.constraint.ConstraintLayout
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"&gt;
  
              &lt;ImageView
                  android:id="@+id/food_image"
                  android:layout_width="320dp"
                  android:layout_height="320dp"
                  android:scaleType="centerCrop"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="parent"
                  app:srcCompat="@drawable/food_image_place_holder" /&gt;
  
              &lt;ImageView
                  android:id="@+id/liked_image"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:padding="4dp"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintTop_toTopOf="parent"
                  app:srcCompat="@drawable/ic_undo_like" /&gt;
          &lt;/android.support.constraint.ConstraintLayout&gt;
      &lt;/android.support.v7.widget.CardView&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          android:layout_marginTop="10dp"&gt;
  
          &lt;TextView
              android:id="@+id/food_name"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:textSize="24sp"
              android:textStyle="bold"
              android:layout_weight="1"
              android:maxLines="1"
              android:ellipsize="end"
              android:layout_marginEnd="4dp"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toBottomOf="@id/food_card" /&gt;
  
          &lt;ImageButton
              android:id="@+id/more_button"
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:background="@android:color/transparent"
              android:src="@drawable/ic_dropdown" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;FrameLayout
          android:id="@+id/tags_frame"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginVertical="10dp" /&gt;
  
      &lt;android.support.v7.widget.CardView
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:minHeight="120dp"&gt;
          &lt;TextView
              android:id="@+id/food_note_back"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@drawable/food_note_background"
              android:scrollbars="vertical"
              android:paddingTop="4dp"
              android:paddingBottom="4dp"
              android:paddingHorizontal="8dp" /&gt;
  
          &lt;TextView
              android:id="@+id/food_note_front"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@drawable/food_note_background"
              android:scrollbars="vertical"
              android:paddingTop="4dp"
              android:paddingBottom="4dp"
              android:paddingHorizontal="8dp" /&gt;
      &lt;/android.support.v7.widget.CardView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Code for RandomFragment:</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:background="@color/whiteSmoke"&gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="?android:attr/colorBackgroundFloating"
          android:elevation="2dp"&gt;
  
          &lt;android.support.constraint.ConstraintLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;TextView
                  android:id="@+id/title_text_view"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="@string/random"
                  android:textSize="20sp"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="parent" /&gt;
  
              &lt;ImageButton
                  android:id="@+id/filter_button"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginEnd="15dp"
                  android:background="@android:color/transparent"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintEnd_toStartOf="@id/menu_button"
                  app:layout_constraintTop_toTopOf="parent"
                  app:srcCompat="@drawable/ic_filter" /&gt;
  
              &lt;ImageButton
                  android:id="@+id/menu_button"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginEnd="10dp"
                  android:background="@android:color/transparent"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintTop_toTopOf="parent"
                  app:srcCompat="@drawable/ic_menu" /&gt;
          &lt;/android.support.constraint.ConstraintLayout&gt;
      &lt;/android.support.v7.widget.Toolbar&gt;
  
      &lt;android.support.v7.widget.CardView
          android:id="@+id/food_card_view"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_gravity="center"
          android:layout_weight="1"
          android:layout_marginHorizontal="20dp"
          android:layout_marginTop="30dp"
          android:background="@android:color/white"
          app:cardCornerRadius="4dp"
          app:cardElevation="4dp"&gt;
          &lt;FrameLayout
              android:id="@+id/food_card_frame"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
      &lt;/android.support.v7.widget.CardView&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_margin="10dp"
          android:padding="10dp"&gt;
  
          &lt;ImageButton
              android:id="@+id/check_button"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:background="@android:color/transparent"
              android:padding="8dp"
              app:srcCompat="@drawable/ic_check" /&gt;
  
          &lt;ImageButton
              android:id="@+id/cross_button"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:background="@android:color/transparent"
              android:padding="8dp"
              app:srcCompat="@drawable/ic_cross" /&gt;
  
          &lt;ImageButton
              android:id="@+id/refresh_button"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:background="@android:color/transparent"
              android:padding="8dp"
              app:srcCompat="@drawable/ic_refresh" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>