TheGMX
TheGMX

Reputation: 153

Android App FullScreen

I'm a beginner android developer and one of the problems that I am facing is how to make my application full screen. I have used the:

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

But it actually just removes the status and the action bar, but it keeps the navigation bar. I tried various different methods without any success, but I know that it's possible since I have lots of apps the do not show the navigation bar like Subway Surfers.

Which is the right way to make it?

Upvotes: 1

Views: 6954

Answers (4)

Vlad
Vlad

Reputation: 910

In your Manifest, you add this line, but you add in between the activity tags that are already there.

Here is the line: android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

This should be working,there is no reason not to,I am sure of that since I recently used this.

Upvotes: 0

fkarg
fkarg

Reputation: 198

You could create a SurfaceView, but it depends on what you want to do if it is useful or not. If you want to make a game, it would probably be useful, but since you might want to use things like Buttons or labels, you can either hide it like described in other answers, or use it (since it gives you an optionMenu with it).

in the end it comes down to what you want to do

Upvotes: 0

Trinimon
Trinimon

Reputation: 13967

Add the following code to your activity:

public class YourActivity 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.your_layout);
        ...
    }
}

p.s.:

Add the following to your onResume() method:

int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;

View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(uiOptions);

Note that it is not possible to remove the navigation bar in all cases (see docs: "it does not hide the system bar on tablets"). Starting from 4.4 on you could enable Immersive Mode. Check out this post related to Android 3.0 devices ("You cannot hide the system bar on Android 3.0.").

Upvotes: 1

user3200451
user3200451

Reputation: 19

// Erase the title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Make it full Screen
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

requestWindowFeature(int windowConstVal) is a method to call on Activity and always you to use a Constant from the Window class that applies a variety of additional features to the window.

getWindow().addFlags() Get the window reference from the current activity and add flags (more features) use a Constant from the windowManager class.

Upvotes: 0

Related Questions