Possible Duplicate:
FullScreen Activity in android?
I'm developing an Android Game and I need to know how to set the application to full screen and how to set the app to Landscape mode only. How should I do this?
Possible Duplicate:
FullScreen Activity in android?
I'm developing an Android Game and I need to know how to set the application to full screen and how to set the app to Landscape mode only. How should I do this?
In your manifest set the following theme to your activity to make it fullscreen.
android:theme="@android:style/Theme.Black.NoTitleBar"
And set this to make it fixed to landscape orientation
android:screenOrientation="landscape"
Inside your xml for the activity place the following:
android:screenOrientation="lands cape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
1. Manifest way - For whole Application
you should specify this feature in your Manifest.xml
- <application>
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"
2. Inside your code - For specific Activity
in your onCreate
method work both these approaches:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
or
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Add this line in AndroidManifest.xml
<activity android:name=".FullScreen" android:label="@string/app_title_home" android:screenOrientation="landscape" />
Edit your activity class like this.
public class FullScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}