开发者

Buttons not displayed when using a SurfaceView

My gameloop class is extended from a SurfaceView. When I try to add a Button either programmaticly or thru XML it is not displayed - I have seen this question asked various times on the net but have found no suitable solutions. Some people have suggested sandwiching the SurfaceView in a FrameLayout but it has made no difference.

I'm surprised more people aren't using regular Buttons in their games and so this question hasn't been answered to death.

Here is my XML: (Engine = Game class that extends a surfaceview)

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

     <com.game.test.Engine
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
     </com.game.test.Engine>

<LinearLayout android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content">

     <Button
    android:id="@+id/btnReset" 
    android:layout_width="80dp" 
    android:layout_height="40dp" 
    android:text="Reset"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true" 
     android:textColor="#FFFFFF"
    android:background="@drawable/custom_button"
    >&开发者_开发百科lt;/Button>
 </LinearLayout> 


I am also seeing this problem....playing around with it a bit, I noticed that if I 'sandwich' the button in a layout to be ABOVE the SurfaceView, the button is displayed....but if the button is below the SurfaceView, it is not displayed. So if you don't mind your button to be above the SurfaceView, you should be OK. I would prefer my buttons to be below the SV, so I'm still looking for a better soluton...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜