The image above is the first page of my game. Normally the big blue 'button' background image should not show up there.
I declare my custom background image for my buttons in layout file like this:
<Button android:id="@+id/id_button_startgame"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_weight="1"
android:textSize="26sp"
android:text="@string/start_game"
android:textColor="@color/solid_red"
android:background="@drawable/button_bg"
/>
And here's button_bg.xml in drawable folder
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/button01_focused" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/button01_pressed" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/button01_pressed" />
<item android:drawable="@drawable/button01_idle" />
</selector>
As you can see the attached image. The three button below is the normal case. I use them everywhere in my apps. But sometimes the one on the center of the screen shows up. This big button cannot be pressed or anything. It's just up there hovering over my game. I can start the game but obviously can't see the content because this big blue thing cover it all.
I can reproduce this bug by keep launching/exiting my game several times.
I'd love to include more info. But don't know what info should I be giving you. I use FrameLayout
to lay the UI above a SurfaceView.
And most of the time this bug DON'T happen. It seems to happen randomly after I launch/exit my game and repeat for several times.
Anyone have seen something like this before? If so please let me know how did you manage to fix it?