【发布时间】:2015-12-17 22:11:50
【问题描述】:
我需要一个带有操作栏的全屏应用。以下方法可以隐藏通知栏(包含电池、rssi、警告等的栏)和导航栏(包含返回、主页、正在运行的应用程序列表)。但是导航栏下的区域仍然无法使用。
我已经从以下帖子中测试了想法
- https://stackoverflow.com/a/27313442/3990512
- Is there a theme for Holo, full screen but with Action Bar?
还有:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoSystemBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowFullscreen">true</item>
</style>
和:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View decorView = getWindow().getDecorView();
decorView.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
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
正如我所说,导航栏下的区域不可用
【问题讨论】:
标签: android fullscreen navigationbar