How to leave Activity in full screen?

Asked

Viewed 3,299 times

1

I have the following Activity:

inserir a descrição da imagem aqui

I would like to remove the bars that are highlighted by the yellow rectangle:

inserir a descrição da imagem aqui

I’ve tried changing Androidmanifest.xml by adding the following line, but the application stops working:

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

Follow my Androidmanifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxx" >  
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:screenOrientation="sensorLandscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>    
</manifest>

My construction class:

package xxx;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //getSupportActionBar().hide();
        setContentView(R.layout.activity_main);
    }

/*    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }*/
}
  • Minimum API: 16
  • Maximum API: 23

1 answer

3


On the website of the android Veloper has a documentation about it. but follows the code snippet for you hide:

View decorView = getWindow().getDecorView();
// Esconde tanto a barra de navegação e a barra de status .
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

and follows the link to study Hiding the Navigation Bar

Browser other questions tagged

You are not signed in. Login or sign up in order to post.