I’m very new to Android programming, so this is probably something pretty basic. I just have an xml layout with a few buttons. I’m trying to follow the model given by the JetBoy demo, so I’m adding a view to the layout which extends SurfaceView. When this new view is put in my xml layout, I just get a blank screen.
Here’s the XML layout if it helps. The gameview element is what causes the screen to be blank
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alwaysDrawnWithCache="true">
<game.test.gameEngine
android:id="@+id/gameView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<Button android:text="Easy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/EasyButton"></Button>
<Button android:text="Medium" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/MedButton"></Button>
<Button android:text="Hard" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/HardButton"></Button>
<DatePicker android:id="@+id/DatePicker01" android:layout_width="wrap_content" android:layout_height="wrap_content"></DatePicker><Button android:id="@+id/Button04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Exit"></Button>
</LinearLayout>
what is game.test.gameEngine? Does it extend the View class? If so, it is taking up the entire screen. you have both width and height set to “fill_parent”, which means that the buttons and datepicker are off the screen. If you want the buttons to appear on top of the game engine view, then you will have to either set the buttons as children of the game engine, or you will have to set the height and width to values that will leave space for the buttons.
embedding and arranging views can be difficult and complicated to learn, so i would suggest looking for code examples similar to what you are doing, as well as browsing the tutorials posted by google on their site.