I have seen certain apps, especially most of the games (Eg. Angry Birds, Temple Run etc) run fullscreen and in landscape mode when launched. Their orientation never changes and they never exit fullscreen when the screen is touched. How its done? What properties do I need to change or code?
Making an Android app run full screen and landscape
Asked Answered
sorry, but it is to common question, just use google and android developer site: developer.android.com/develop/index.html; google.com –
Benn
Two quick Google searches revealed the answers to your questions. Force fullscreen on an activity: androidsnippets.com/how-to-make-an-activity-fullscreen Force orientation on an activity: #2150787 –
Andaman
I have Googled it but in vain. In the Android Developers website, I couldn't figure it out despite going through all the properties etc. –
Mizzle
Yet another example of how pathetic "SO fundamentalism" can be. You could say "Use Google" to a massive number of SO questions, many of them with tens or hundreds of votes. Nobody seems to complain about them. –
Sunshine
If you prefer to use XML, you can change the AndroidManifest.xml:
<activity android:name="..."
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>
If you are targetting Android SDK 9 or above, you can use sensorLandscape
instead of landscape
which will mean that the screen will look the correct way up on both normal landscape orientation and reverse landscape orientation.
If set min sdk = 8, and use sensorLandscape in manifest, does application crash? –
Ripon
import android.view.Window;
import android.view.WindowManager;
import android.content.pm.ActivityInfo;
@Override public void onCreate(Bundle savedInstanceState)
{
...
// Set window fullscreen and remove title bar, and force landscape orientation
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
...
}
Solution to your problem
Its Much better...to add this into your respective activities –
Saddlecloth
The problem is solved, and based on the answers given above, what I did was,
Step 1 : In the manifest.xml file,
<application
. . .
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
. . .
</application>
Step 2 : In the Java file, I made the following changes,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
and now my app runs fullscreen, landscape without any issues. Thank You all.
Put this in onCreate()
in every activity class (screens):
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
This code will disable android notification bar ( pull up to down ). !!!
© 2022 - 2024 — McMap. All rights reserved.