I'm working on a New Game - Player Selection layout. It consists of a single RelativeLayout inside a ScrollView that takes up the whole width and height. The RelativeLayout will have several TextViews, EditTexts, and Spinners. These will allow the user to select the number, type and name for each player in the game.
The layout looks just fine in Portrait screen orientation. But once I slide out the hardware keyboard of the G1 to type in a player's name, the entire view goes completely blank / black (well, the dark gray color of the background).
All widgets/views disappear, and I can only see the Android status bar at top and the application title bar.
If I slide the keyboard back in, the screen remains the same... all dark gray with none of the TextViews, EditTexts, Spinners visible. If I press Home, then go back into the application, then after a few seconds the view is back to how it should look... but only in portrait mode with the keyboard slid in. I can't get it to display the widgets in landscape mode.
Here's sky_new_game.xml:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:scrollbars="none">
- <RelativeLayout
- android:id="@+id/new_game_rel_layout"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android"
- >
- <TextView
- android:id="@+id/txt_new_game_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/new_game_title"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true" android:paddingBottom="20px" android:textSize="20sp" android:textStyle="bold" android:paddingLeft="5px"/>
- <!-- PLAYER 1 -->
- <TextView
- android:id="@+id/txt_p1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/p1"
- android:layout_below="@+id/txt_new_game_title"
- android:layout_alignParentLeft="true"
- android:paddingBottom="5px"
- android:paddingLeft="5px"
- android:paddingTop="10px"
- android:textSize="16sp"
- android:textStyle="bold"
- android:paddingRight="30px"/>
- <Spinner
- android:id="@+id/spin_p1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@+id/txt_new_game_title"
- android:layout_toRightOf="@+id/txt_p1"
- android:drawSelectorOnTop="true"
- android:prompt="@string/p1_prompt"
- />
- <TextView
- android:id="@+id/txt_p1_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/p_name"
- android:layout_below="@+id/spin_p1"
- android:layout_alignParentLeft="true"
- android:paddingBottom="5px"
- android:paddingLeft="5px"
- android:paddingTop="10px"
- android:textSize="16sp"
- android:textStyle="bold"
- android:paddingRight="30px"/>
- <EditText
- android:id="@+id/edit_txt_p1_name"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/p1_name"
- android:textSize="18sp"
- android:layout_below="@+id/spin_p1"
- android:layout_alignLeft="@+id/spin_p1"
- />
- <Button
- android:id="@+id/but_start_game"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_below="@+id/edit_txt_p1_name"
- android:text="@string/start_game"
- />
- </RelativeLayout>
- </ScrollView>
Parsed in 0.008 seconds, using GeSHi 1.0.8.4
And to display this layout I am simply calling setContentView():
Using java Syntax Highlighting
- setContentView(R.layout.sky_new_game);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
I know you can create the folder layout-land under the res folder, and put an alternate layout XML file in there to handle the landscape orientation, but I'd like to avoid this if possible because as far as I can tell the original version I posted above should work just fine. It's using a RelativeLayout which should adjust to the different screen resolution, unless I am mistaken.
Does this problem have to do with using a ScrollView? Is there something else I am missing? Any help would be greatly appreciated!



