开发者

Overlay view sometimes doesn't draw

I recently updated my phone to gingerbread and to my horror one of my apps stopped working!

The app consists of a SurfaceView and a layout (view) that shows up as an overlay over this SurfaceView.

THe xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >

  <com.mycompany.MySurfaceView
    android:id="@+id/myview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"    
  />

  <include layout="@layout/settings"
  android:layout_alignTop="@id/myview"
  android:visibility="invisible"
  android:id="@+id/settings"
  />

</RelativeLayout>

When the user press the menu button I use this code to show the view:

View settings = (View)findViewById(R.id.settings);
settings.setVisibility(View.VISIBLE);

This worked flawlessy on versions earlier than 2.3 but now the behaviour is very random.

Observations

Very rarely everything works.

Sometimes the view shows up after hiding / unhiding it.

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.

The getVisibility method always report the correct value.

What I've tried

Rebuilding draw cache

Using BringToFront method

Post invalidate

Setting the initial value of the view to "visible", th开发者_Python百科is makes everything work, but I really want it to be initially invisible!

If anyone wants to check the problem you can try it for yourself in my app (it's on market, search for "chainparticles").

Thanks!


Solved it by changing the views initial state to "gone". WTF?!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜