title: Divide Screen into Four Equal Parts using Relative Layout
body: <p>I currently have code that allows me to divide the screen into four equal parts, with an image button in each part. However, the code uses linear layouts which brings up the suggestion "nested weights are bad for performance". How can I make my layout using relative layouts?
  Below is the code, and here is a picture of the intended format<br>
  <img src="https://i.stack.imgur.com/KCvTb.png" alt="enter image description here">
      
      </p>
  
  <pre><code>    &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="1.0"
  
          android:orientation="horizontal"
          android:background="#ff191919"&gt;
  
          &lt;ToggleButton
              android:id="@+id/button1"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#ff414141"
              android:layout_weight="1.0"
              android:text="Plane"
              android:layout_margin="5dp"
              android:textSize="20sp"
              android:onClick="airplaneClicked"/&gt;
  
  
          &lt;ImageButton
              android:id="@+id/button2"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#ff414141"
              android:layout_weight="1.0"
              android:layout_margin="5dp"
              android:scaleType="fitCenter"
              android:src="@drawable/ic_brightness"/&gt;
  
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="1.0"
          android:orientation="horizontal"
          android:background="#ff191919"&gt;01
  
          &lt;ImageButton
              android:id="@+id/button3"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#ff414141"
              android:layout_weight="1.0"
              android:layout_margin="5dp"
              android:scaleType="fitCenter"
              android:src="@drawable/ic_sound" /&gt;
  
  
          &lt;ImageButton
              android:id="@+id/settingsbutton"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#ff414141"
              android:layout_weight="1.0"
              android:layout_margin="5dp"
      android:scaleType="fitCenter"
      android:src="@drawable/settings2"/&gt;
  
      &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  </code></pre>