title: Overlay view sometimes doesn't draw
body: <p>I recently updated my phone to gingerbread and to my horror one of my apps stopped working!</p>
  
  <p>The app consists of a SurfaceView and a layout (view) that shows up as an overlay over this SurfaceView.</p>
  
  <p>THe xml looks like this:</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;com.mycompany.MySurfaceView
      android:id="@+id/myview"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"    
    /&gt;
  
    &lt;include layout="@layout/settings"
    android:layout_alignTop="@id/myview"
    android:visibility="invisible"
    android:id="@+id/settings"
    /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>When the user press the menu button I use this code to show the view:</p>
  
  <pre><code>View settings = (View)findViewById(R.id.settings);
  settings.setVisibility(View.VISIBLE);
  </code></pre>
  
  <p>This worked flawlessy on versions earlier than 2.3 but now the behaviour is <em>very</em> random.</p>
  
  <p><strong>Observations</strong></p>
  
  <p>Very rarely everything works.</p>
  
  <p>Sometimes the view shows up after hiding / unhiding it.</p>
  
  <p>Sometimes you can press the buttons on the view (even though it's invisible) this makes the view show up for the rest of the application lifetime.</p>
  
  <p>The getVisibility method always report the correct value.</p>
  
  <p><strong>What I've tried</strong></p>
  
  <p>Rebuilding draw cache</p>
  
  <p>Using BringToFront method</p>
  
  <p>Post invalidate</p>
  
  <p>Setting the initial value of the view to "visible", this makes everything work, but I really want it to be initially invisible!</p>
  
  <p>If anyone wants to check the problem you can try it for yourself in my app (it's on market, search for "chainparticles").</p>
  
  <p>Thanks!</p>