2015-11-14 27 views
7

Come posso nascondere la barra di stato per un'attività specifica?Come nascondere la barra di stato?

Ho trovato questa domanda simile, ma nessuna delle risposte ha funzionato per me. L'app si è bloccata ogni volta che ho provato ad andare all'attività: How to hide status bar in Android

Grazie.

+0

http://stackoverflow.com/questions/33692388/android-remove-actionbar-title-keeping-toolbar-menu/33692402#33692402 –

+0

barra di stato è quello che voglio rimosso, non barra delle azioni . – user5495265

risposta

15

Prova questo in voi l'attività prima di impostare i tuoi contenuti

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
+0

Ha funzionato, ma funziona per tutte le versioni di Android? – user5495265

+0

sì funzionerà per tutte le versioni di Android –

3

nascondere la barra di stato su Android 4.0 e Bassa

  1. Impostando il tema di applicazione nel file di manifest.xml.

    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" 
    

    O

  2. Scrivendo il codice Java in modo onCreate() di attività.

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        // If the Android version is lower than Jellybean, use this call to hide 
        // the status bar. 
        if (Build.VERSION.SDK_INT < 16) { 
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
           WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        } 
        setContentView(R.layout.activity_main); 
    } 
    

nascondere la barra di stato su Android 4.1 e superiore

Scrivendo codice Java in() metodo di attività onCreate.

View decorView = getWindow().getDecorView(); 
// Hide the status bar. 
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; 
decorView.setSystemUiVisibility(uiOptions); 
// Remember that you should never show the action bar if the 
// status bar is hidden, so hide that too if necessary. 
ActionBar actionBar = getActionBar(); 
actionBar.hide(); 
1
if (Build.VERSION.SDK_INT < 16)//before Jelly Bean Versions 
{ 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
         WindowManager.LayoutParams.FLAG_FULLSCREEN); 
} 
else // Jelly Bean and up 
{ 
    View decorView = getWindow().getDecorView(); 
    // Hide the status bar. 
    int ui = View.SYSTEM_UI_FLAG_FULLSCREEN; 
    decorView.setSystemUiVisibility(ui); 

    //Hide actionbar 
    ActionBar actionBar = getActionBar(); 
    actionBar.hide(); 
}