title: Change object width and height without hard-coding xml values
body: <p>I am creating a home page for my android application in Android Studios. In the layouts folder I have my home page activity XML file. The home page will contain 3 clickable "boxes" which are CardViews. They are functioning correctly but <strong>I am working to change the CardViews sizes without hard-coding XML width and height</strong> (or other objects in the future). So that the sizes change properly according to different screen sizes.
  In this specific case <strong>I want to increase the height of the CardViews.</strong></p>
  
  <p><a href="https://i.stack.imgur.com/0iDGg.png" rel="nofollow noreferrer">Capture Receipt and Create Invoice CardViews I want to modify size of.</a></p>
  
  <p>I am using a Linear Layout inside a Constraint Layout. The CardViews layout_width and layout_height are selected to match parent. I have modified the layout_weight, but this does not get the result I am looking for. <strong>I want to increase the heights without increasing the width.</strong></p>
  
  <p><strong>Is this something to be done in XML or the Java part of the code?</strong></p>
  
  <p>Here is my home page activity XML code (without the Bottom Nav bar and Add Item part):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;android.support.constraint.ConstraintLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".HomePageActivity"&gt;
  
     &lt;LinearLayout
      android:id="@+id/ll"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/lightComplimentGrey"
      android:gravity="center|top"
      android:orientation="vertical"
      tools:context=".MainActivity"
      tools:layout_editor_absoluteX="0dp"
      tools:layout_editor_absoluteY="0dp"&gt;
  
  
          &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="290dp"
          android:background="@drawable/curved_top"
          android:orientation="horizontal"
          android:paddingBottom="-50dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"&gt;
  
  
              &lt;android.support.constraint.ConstraintLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              app:layout_constraintBottom_toTopOf="@+id/ll"&gt;
  
                  &lt;TextView
                  android:id="@+id/currentUserTextView"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginStart="8dp"
                  android:layout_marginTop="8dp"
                  android:layout_marginEnd="188dp"
                  android:layout_marginBottom="8dp"
                  android:gravity="left"
                  android:text="Current User"
                  android:textColor="#99E8F3"
                  android:textSize="20sp"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintHorizontal_bias="0.922"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="parent"
                  app:layout_constraintVertical_bias="0.352" /&gt;
  
                  &lt;TextView
                  android:id="@+id/userNameEntryTextView"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="8dp"
                  android:layout_marginEnd="8dp"
                  android:layout_marginBottom="8dp"
                  android:gravity="left"
                  android:hint="Not Signed In"
                  android:textColor="#FFFFFF"
                  android:textColorHint="#FFFFFF"
                  android:textSize="24sp"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintHorizontal_bias="0.0"
                  app:layout_constraintStart_toStartOf="@+id/currentUser"
                  app:layout_constraintTop_toTopOf="parent" /&gt;
  
                  &lt;Spinner
                  android:id="@+id/changeUserSpinner"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentTop="true"
                  android:layout_centerHorizontal="true"
                  android:layout_marginTop="8dp"
                  android:backgroundTint="#FFFFFF"
                  app:layout_constraintBottom_toBottomOf="@+id/
                  app:layout_constraintStart_toEndOf="@+id/userNameEntry"
                  app:layout_constraintTop_toTopOf="@+id/currentUserTextView"
                  app:layout_constraintVertical_bias="0.558" /&gt;
  
                  &lt;ImageButton
                  android:id="@+id/menuButton"
                  android:layout_width="0dp"
                  android:layout_height="wrap_content"
                  android:layout_marginStart="16dp"
                  android:layout_marginTop="8dp"
                  android:layout_marginBottom="8dp"
                  android:layout_weight="4"
                  android:background="@drawable/ic_menu_light_blue_24dp"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="parent"
                  app:layout_constraintVertical_bias="0.048" /&gt;
  
                  &lt;ImageButton
                  android:id="@+id/notificationButton"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginStart="8dp"
                  android:layout_marginTop="16dp"
                  android:layout_marginEnd="16dp"
                  android:layout_marginBottom="
                  android:background="@drawable/ic_tooLongToPost"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintHorizontal_bias="1.0"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="parent"
                  app:layout_constraintVertical_bias="0.0" /&gt;
  
              &lt;/android.support.constraint.ConstraintLayout&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="-70dp"
          android:clipToPadding="false"
          android:gravity="center"
          android:orientation="horizontal"&gt;
  
  
              &lt;android.support.v7.widget.CardView
              android:id="@+id/capture_receipt"
              android:layout_width="0px"
              android:layout_weight="1"
              android:layout_height="wrap_content"
              android:layout_margin="@dimen/view_margin_normal_screen"
              android:clickable="true"
              android:foreground="?android:attr/selectableItemBackground"&gt;
  
                  &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:gravity="center"
                  android:orientation="vertical"&gt;
  
                      &lt;ImageView
                      android:layout_width="64dp"
                      android:layout_height="64dp"
                      android:background="@drawable/circle_background_green"
                      android:padding="10dp"
                      android:src="@drawable/ic_photo_camera_black_24dp" /&gt;
  
                      &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_marginTop="10dp"
                      android:text="Capture Receipt"
                      android:textStyle="bold" /&gt;
  
                      &lt;View
                      android:layout_width="match_parent"
                      android:layout_height="1dp"
                      android:layout_margin="10dp"
                      android:background="@color/lightComplimentGrey" /&gt;
  
                      &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:gravity="center"
                      android:padding="5dp"
                      android:text="Scan receipt to recognize items"
                      android:textColor="@android:color/darker_gray" /&gt;
  
                  &lt;/LinearLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p>How is it possible to modify the heights and widths (just like you would when hard coding the XML) without hard-coding?</p>