I have a custom view called GameView where my game is drawn. There is also a child-view called PausedView that works as an overlay for GameView. When the game is paused, the PausedView is set to visible and the screen gets a 50% opacity black overlay and 4 buttons.
My problem is that on my LG Optimus S (Android 2.3.3) Those buttons do not appear. They are there and you can click on then, but they aren’t shown. Furthermore, the black overlay only appears on buttons and textviews within GameView. If I navigate away from, then back to the Activity, it all appears normal.
This bug doesn’t happen on my Motorola Xoom (Android 3.2.1) or my Motorola Droid (Android 2.2.3). It also didn’t happen on my Optimus until recently (I think around the time I got a service update).
screenshots of what I’m talking about:
http://postimage.org/image/qjhiho3ed/
http://postimage.org/image/9k8k2es6t/
I’ve tried calling postInvalidate() on the GameView and the PausedView, but it didn’t help.
Has anyone encountered anything like this?
update:
I tried removing the invisibility setting from XML and using this code, but it still isn’t working. I was able to rectify it by calling setVisibility on the views long after they had been created, but I can’t find the right place to call those functions during creation.
// Use XML layout
setContentView(R.layout.main);
// define the views of this activity
gameView = (GameView)findViewById(R.id.gameView);
pausedView = findViewById(R.id.pausedView);
victoryView = findViewById(R.id.victory);
pausedView.setVisibility(View.INVISIBLE);
victoryView.setVisibility(View.INVISIBLE);
update:
fixed it by using
pausedView.setVisibility(View.GONE);
victoryView.setVisibility(View.GONE);
Yes, I think i have encountered something similar.
In my application, I’ve got a FrameView with an image source and an overlay. On my Android 4.0.3 device it appears fine, but with 2.3.x devices (or earlier) they don’t appear when being set to visible.
My only solution so far is to not set the views invisible in the XML file and to turn them invisible (or gone) right after the layout has been inflated. After that, everything seems to work fine.