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

哦,是的。错误。 –