title: RelativeLayout not handling "toLeftOf" and/or toRightOf correctly
body: <p>I have been looking for a solution to the issue with &quot;toLeftOf&quot; and &quot;toRightOf&quot; when using RelativeLayout, but haven't found a real solution or good answer to this behaviour:</p>
  <p>Basically, &quot;toLeftOf&quot; isn't working too well.</p>
  <p>I have two EditText, and I want an image to be displayed to the left of each EditText. When I try to do that, I get the following result (Eclipse editor):</p>
  <p><img src="https://i.stack.imgur.com/pRWVe.png" alt="enter image description here" /></p>
  <p>As you can see, the images are not shown at all. Here is the XML used:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;fill_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginLeft=&quot;30dp&quot;
      android:layout_marginRight=&quot;30dp&quot;
      android:layout_marginTop=&quot;35dp&quot;
      android:background=&quot;#010101&quot;
      android:gravity=&quot;center_horizontal&quot;
      android:orientation=&quot;vertical&quot; &gt;
  
      &lt;EditText
          android:id=&quot;@+id/login_carNumber&quot;
          style=&quot;@style/EditTextDark&quot;
          android:layout_width=&quot;fill_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:hint=&quot;@string/prompt_carNumber&quot;
          android:inputType=&quot;phone&quot;
          android:textAppearance=&quot;?android:attr/textAppearanceMedium&quot;
          android:textCursorDrawable=&quot;@null&quot; &gt;
  
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/login_car_icon&quot;
          android:layout_width=&quot;40dp&quot;
          android:layout_height=&quot;40dp&quot;
          android:src=&quot;@drawable/user&quot;
          android:layout_toLeftOf=&quot;@id/login_carNumber&quot; /&gt;
  
      &lt;EditText
          android:id=&quot;@+id/login_password&quot;
          style=&quot;@style/EditTextDark&quot;
          android:layout_width=&quot;fill_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_below=&quot;@id/login_carNumber&quot;
          android:layout_marginTop=&quot;10dp&quot;
          android:hint=&quot;@string/prompt_password&quot;
          android:inputType=&quot;phone&quot;
          android:textAppearance=&quot;?android:attr/textAppearanceMedium&quot;
          android:textCursorDrawable=&quot;@null&quot; &gt;
      &lt;/EditText&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/login_lock_icon&quot;
          android:layout_width=&quot;40dp&quot;
          android:layout_height=&quot;40dp&quot;
          android:src=&quot;@drawable/lock&quot;
          android:layout_toLeftOf=&quot;@id/login_password&quot; /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p><strong>Firstly, why isn't this working?</strong></p>
  <p>If I change the XML, and use &quot;toRightOf&quot; on the EditTexts instead of &quot;toLeftOf&quot; on the images, then I get the follow results:</p>
  <p><img src="https://i.stack.imgur.com/Csj9u.png" alt="enter image description here" /></p>
  <p>As you can see, both images are shown, but they are &quot;on top of each other&quot;, when the padlock should be on the left side of the second EditText. Here is the XML:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;fill_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginLeft=&quot;30dp&quot;
      android:layout_marginRight=&quot;30dp&quot;
      android:layout_marginTop=&quot;35dp&quot;
      android:background=&quot;#010101&quot;
      android:gravity=&quot;center_horizontal&quot;
      android:orientation=&quot;vertical&quot; &gt;
  
      &lt;EditText
          android:id=&quot;@+id/login_carNumber&quot;
          style=&quot;@style/EditTextDark&quot;
          android:layout_width=&quot;fill_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_toRightOf=&quot;@+id/login_car_icon&quot;
          android:hint=&quot;@string/prompt_carNumber&quot;
          android:inputType=&quot;phone&quot;
          android:textAppearance=&quot;?android:attr/textAppearanceMedium&quot;
          android:textCursorDrawable=&quot;@null&quot; &gt;
  
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/login_car_icon&quot;
          android:layout_width=&quot;40dp&quot;
          android:layout_height=&quot;40dp&quot;
          android:src=&quot;@drawable/user&quot; /&gt;
  
      &lt;EditText
          android:id=&quot;@+id/login_password&quot;
          style=&quot;@style/EditTextDark&quot;
          android:layout_width=&quot;fill_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_below=&quot;@id/login_carNumber&quot;
          android:layout_marginTop=&quot;10dp&quot;
          android:layout_toRightOf=&quot;@+id/login_lock_icon&quot;
          
          android:hint=&quot;@string/prompt_password&quot;
          android:inputType=&quot;phone&quot;
          android:textAppearance=&quot;?android:attr/textAppearanceMedium&quot;
          android:textCursorDrawable=&quot;@null&quot; &gt;
      &lt;/EditText&gt;
  
      &lt;ImageView
          android:id=&quot;@+id/login_lock_icon&quot;
          android:layout_width=&quot;40dp&quot;
          android:layout_height=&quot;40dp&quot;
          android:src=&quot;@drawable/lock&quot; 
          /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p><strong>Second question; why is the &quot;padlock&quot; image on top of the first image, and not directly to the left of the second EditText?</strong></p>
  <p>If I now add the following line to the last ImageView (the padlock image):</p>
  <pre><code>android:layout_below=&quot;@+id/login_car_icon&quot;
  </code></pre>
  <p>it is placed correctly, but I think its a &quot;hack&quot; and should not be necessary, right?</p>
  <p>So, the last ImageView has the following XML to work:</p>
  <pre><code>&lt;ImageView
      android:id=&quot;@+id/login_lock_icon&quot;
      android:layout_width=&quot;40dp&quot;
      android:layout_height=&quot;40dp&quot;
      android:src=&quot;@drawable/lock&quot; 
      android:layout_below=&quot;@+id/login_car_icon&quot;
      /&gt;
  </code></pre>
  <p>Result:</p>
  <p><img src="https://i.stack.imgur.com/7t3uX.png" alt="enter image description here" /></p>
  <p>Lastly; why is this needed to make the image to the left of the last EditText?</p>