Can't get android:layout_weight to work
<p>I am trying to draw some boxes in my activity, which will contain other layout elements, in XML. I want to do this using the relative dimensions, e.g. specify half of the height of the screen for each box. I understand that the correct way to do this is to set the initial height to 0px and use layout_weight, but I can't get the following example to work. I am expecting it to draw two identical rectangles (defined in /drawable/rect) in different vertical halves of the screen, but the screen is blank: </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"&gt;
 &lt;ImageView
android:src="@drawable/rect"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:scaleType="fitXY"
  android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"/&gt;
 &lt;ImageView
android:src="@drawable/rect"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
  android:layout_width="fill_parent"
android:scaleType="fitXY"
android:layout_height="0px"
android:layout_weight="1"/&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>Does anyone have any ideas?</p>
