4

我想創建一個全屏幕的活動。在沒有上述類似通知欄和下方沒有像主頁鍵式etc.I時能夠得到這一點,但也想要刪除以下家庭按鈕欄:全屏沒有導航和狀態欄

enter image description here

這是我的代碼。

<style name="MyScreen" parent="@style/Theme.AppCompat.Light"> 
    <item name="windowNoTitle">true</item> 
    <item name="windowActionBar">false</item> 
    <item name="android:windowFullscreen">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
</style> 

回答

7

你需要什麼叫做Immersive Full-Screen Mode

enter image description here

// This snippet hides the system bars. 
private void hideSystemUI() { 
    // Set the IMMERSIVE flag. 
    // Set the content to appear under the system bars so that the content 
    // doesn't resize when the system bars hide and show. 
    mDecorView.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); 
} 

// This snippet shows the system bars. It does this by removing all the flags 
// except for the ones that make the content appear under the system bars. 
private void showSystemUI() { 
    mDecorView.setSystemUiVisibility(
      View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
      | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); 
} 
+0

感謝。它有幫助。 –

+1

@MuhammadHasnain請將答案標爲正確的一個 –

-2

編程做在你的活動類:

public class ActivityMain extends AppCompatActivity { 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     // this will remove title 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN); 

     setContentView(R.layout.main); 
    } 
} 
+0

謝謝你。但我選擇沉浸式全屏方式來獲得我想要的結果。 –

+0

哦,是的。錯誤。 –