Android - draw squares in xml
<p>I'd like to draw three squares side-by-side in xml, so that they fill the screen horizontally (minus a margin of 12 dp on each side).  According to <a href="http://stackoverflow.com/questions/2843087/android-alignment-of-four-squares">this post</a> it seems possible to do this messily with table layouts, but I'm wondering if there's a better way.  Here's my attempt using nested LinearLayouts, which draws rectangles which fill the entire screen vertically but otherwise does what I'm looking for:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="12dp"
    android:background="#ffffff"
    android:baselineAligned="false"
    android:orientation="horizontal" &gt;
    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="@drawable/rectangle" &gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:background="@drawable/rectangle" &gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:background="@drawable/rectangle" &gt;
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>
