2017-07-31 2 views
2

J'utilise ci-dessous code pour utiliser Immersive mode plein écran:espace blanc lors de l'utilisation Immersive mode plein écran dans Android

getWindow().getDecorView().setSystemUiVisibility(
     View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
      | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
      | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar 
      | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar 
      | View.SYSTEM_UI_FLAG_IMMERSIVE); 

Mais quand je lance mon application, un espace blanc montre au lieu de notification et barre inférieure . Je pense que j'ai une erreur dans mon fichier XML. Voici mon fichier XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#303030" 
    tools:context="programsimple.game.FullscreenActivity"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     android:background="#eeeeee"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@drawable/background"/> 

     <Button 
      android:layout_width="110dp" 
      android:layout_height="70dp" 
      android:background="@drawable/button_shape" 
      android:layout_centerVertical="true" 
      android:id="@+id/btnStartGame" 
      android:layout_centerHorizontal="true" 
      android:text="شروع" 
      android:textSize="25sp" 
      android:textColor="#97d2ff"/> 

    </RelativeLayout> 

</FrameLayout> 

-t-il une erreur?

mise à jour: Je teste avec KitKat.

Répondre

4

La couleur blanche est due à l'arrière-plan défini dans RelativeLayout. Pour retirer la barre blanche en bas, il suffit d'enlever cette étiquette de RelativeLayout:

android:fitsSystemWindows="true" 

Il est ajouté lorsque l'application est créée et ajoute un rembourrage général à la mise en page pour faire en sorte que le contenu ne se chevauchent pas les fenêtres du système.

+0

Je pense que c'est android: fitsSystemWindows = "true", voir les s dans les fits. –

+0

@RakeshYadav Merci pour la correction, n'a pas remarqué que! – Abhi