title: Circular dependencies cannot exist in RelativeLayout
body: <p>I am rendering a View into a <code>Bitmap</code>. I need a balloon with a pointer at the top or at the bottom, based on if it fits on the screen. For that I use a <code>RelativeLayout</code>, because I need the pointers to be partially over the balloon:</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="wrap_content"
      android:layout_height="wrap_content"
      &gt;
  
      &lt;LinearLayout android:id="@+id/balloon_body"
          android:layout_width="@dimen/pins_details_balloon_width"
          android:layout_height="wrap_content"
          android:layout_marginTop="-1dp"
          android:layout_marginBottom="-1dp"
          android:layout_below="@+id/pointer_top"
          android:orientation="vertical"
          &gt;
  
          &lt;TextView android:id="@android:id/title"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="4dp"
              /&gt;
  
          &lt;TextView android:id="@android:id/text1"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="4dp"
              /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;ImageView android:id="@id/pointer_top"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          /&gt;
  
      &lt;ImageView android:id="@+id/pointer_bottom"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@id/balloon_body"
          /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I inflate this view and then I want to measure and layout it, so I can render it into a bitmap:</p>
  
  <pre><code>view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
  //view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
  view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
  //view.measure(View.MeasureSpec.makeMeasureSpec(3000, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(3000, View.MeasureSpec.AT_MOST));
  view.layout(0, 0, s_View.getMeasuredWidth(), s_View.getMeasuredHeight());
  </code></pre>
  
  <p>This code crashes on the <em>view.measure(...)</em> with the <strong>Circular dependencies cannot exist in RelativeLayout</strong> error. I tried different <em>LayoutParams</em> (without setLayoutParams(...) the <em>measure(...)</em> crashes with a null pointer exception), different <em>View.MeasureSpec</em>-s but no success. If I remove the <strong>android:layout_below="@id/balloon_body"</strong> in the last ImageView, it works, but the bottom pointer is at the top.</p>
  
  <p>I cannot use a LinearLayout, because I need those pointers to be above the body of the balloon, where with LinearLayout the top pointer will be below it. Where is the problem and how can I achieve what I want?</p>