Skip to content Skip to sidebar Skip to footer

Android Fullscreen Not Working: Gingerbread

I am trying to make a fullscreen activity, but it doesn't seem to work in GingerBread, here is my code @SuppressLint('NewApi') @Override public void onCreate(Bundle savedInstanceS

Solution 1:

First of all you should set the activity as full screen in the manifest. In the desired activity, add this code

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

and your onCreate should be like this

if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD){
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

setContentView(R.layout.main);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
    ActionBaractionBar= getActionBar();
    actionBar.hide();

}

This might solve the problem.

Solution 2:

Remember that you must call requestWindowFeature before call setContentView

Try this to make a full screen activity by java:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

and in Manifest

android:theme="@android:style/Theme.Translucent.NoTitleBar"

Solution 3:

requestWindowFeature has to be called before super.onCreate. Like so:

@SuppressLint("NewApi")@OverridepublicvoidonCreate(Bundle savedInstanceState) {

    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD){
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_eyes);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
        ActionBaractionBar= getActionBar();
        actionBar.hide();
    }

    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD){
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    // ...

If this doesn't work, move the getWindow().setFlags(...) call to the top as well.

Solution 4:

Unless you have a reason to not setting it in your manifest, add this attribute to your tag in the Manifest:

<applicationandroid:theme="@android:style/Theme.NoTitleBar.Fullscreen".....
>

And I believe you wouldn't need the if-conditions code in the onCreate().

Solution 5:

isn't just android:theme ="@android:style/Theme.NoTitleBar.Fullscreen" both hides the titlebar and the notification area?

it equals to:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);

I learn this from https://github.com/pocorall/scaloid-apidemos/blob/master/src/main/java/com/example/android/apis/graphics/CameraPreview.java

Post a Comment for "Android Fullscreen Not Working: Gingerbread"