title: 2x2 GridLayout with squares
body: <p>I want a 2x2 grid layout, that fills the whole width of the screen with CardViews that are squares. </p>
  
  <p>Currently, I have this</p>
  
  <p><a href="https://i.stack.imgur.com/CDgpm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CDgpm.png" alt="enter image description here"></a></p>
  
  <p>The CardViews are being stretched to the height of the GridLayout. How can I make it so that the CardView heights are matching its widths so I have squares?</p>
  
  <p>My current XML looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
  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:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.example.jonas.trainingslog1.Activity_Settings"
  android:orientation="vertical"&gt;
  
  &lt;GridLayout
      android:layout_width="match_parent"
      android:layout_height="600dp"
      android:columnCount="2"
      android:rowCount="2"
      android:alignmentMode="alignMargins"
      android:columnOrderPreserved="false"
      android:layout_margin="16dp"&gt;
  
      &lt;android.support.v7.widget.CardView
          android:layout_width="0dp"
          android:layout_height="0dp"
          android:layout_columnWeight="1"
          android:layout_rowWeight="1"
          android:layout_margin="16dp"/&gt;
  
      &lt;android.support.v7.widget.CardView
          android:layout_width="0dp"
          android:layout_height="0dp"
          android:layout_columnWeight="1"
          android:layout_rowWeight="1"
          android:layout_margin="16dp"/&gt;
  
      &lt;android.support.v7.widget.CardView
          android:layout_width="0dp"
          android:layout_height="0dp"
          android:layout_columnWeight="1"
          android:layout_margin="16dp"
          android:layout_rowWeight="1" /&gt;
  
      &lt;android.support.v7.widget.CardView
          android:layout_width="0dp"
          android:layout_height="0dp"
          android:layout_columnWeight="1"
          android:layout_rowWeight="1"
          android:layout_margin="16dp"/&gt;
  
  
  &lt;/GridLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have searched a lot but nothing really helped yet, any advice is welcomed! </p>