[Solved] Programmatically make app FULL SCREEN in Android

I know that an app can be made full screen by tag in the manifest of the activity android:theme="@android:style/Theme.NoTitleBar.Fullscreen" Is it possible to switch to full screen mode from within the app, programmatically?

Enquirer: Wesley

||

Solution #1:

add two lines…

requestWindowFeature(Window.FEATURE_NO_TITLE); 
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
Respondent: Samir Mangroliya

Solution #2:

You can create new style and add

<item name="android:windowFullscreen">true</item>

Or you can do it programmatically:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Respondent: krystian71115

Solution #3:

add this in Activity onCreate before setContentView:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // remove title
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);
}

and in AndroidManifest.xml file:

<activity android:name=".ActivityName"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>
Respondent: ρяσѕρєя K

Solution #4:

If you need a fullscreen immersive mode (for games, galleries, etc.), here is the solution I use and recommend.

The most efficient way is to set the SystemUIVisibility only when is needed:

  1. In your onCreate()
  2. With OnSystemUIChangeListener when the fullscreen mode is lost

public class BaseActivity extends Activity {

@SuppressLint("InlinedApi")
private static final int UI_OPTIONS = View.SYSTEM_UI_FLAG_LOW_PROFILE
        | View.SYSTEM_UI_FLAG_FULLSCREEN
        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;        

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Step 1
    hideSystemUI();

    // Step 2
    getWindow().getDecorView()
               .setOnSystemUiVisibilityChangeListener(new View
               .OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                hideSystemUI();
            }
        }
    });
}

private void hideSystemUI() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) actionBar.hide();
    getWindow().getDecorView().setSystemUiVisibility(UI_OPTIONS);
}

}

Solution #5:

Try this,

// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                     WindowManager.LayoutParams.FLAG_FULLSCREEN);
                     setContentView(R.layout.main);

or

<activity android:name=".ActivityName"
 android:label="@string/app_name"
 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
Respondent: Nandha Krishnan

Solution #6:

in onCreate() method write

requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

Respondent: dileep krishnan

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published. Required fields are marked *

New ride at Perth's Adventure World a ‘swing on steroids’ - Australasian Leisure Management npp pharma the truth about anabolic steroid drugs and professional sports