带标题栏的全屏 Activity(导航栏下的区域不可用!)
FullScreen Activity with TitleBar (Area under Navigationbar is unusable!)
我需要一个带操作栏的全屏应用程序。以下方法可以隐藏通知栏(包含电池、RSSI、警告等的栏)和 Navigation-bar(包含返回、首页、运行 应用程序列表)。但是Navigation-bar下的区域还是不能用。
我测试了以下帖子中的想法
- 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);
正如我所说,下面的区域Navigation-bar不可用
如果需要,您可以使用 Theme.AppCompat.Light.
并在视图层次结构中放置一个工具栏。
工具栏是操作栏的新替代品,请检查此 post:http://android-developers.blogspot.pt/2014/10/appcompat-v21-material-design-for-pre.html
这样你的布局就有了完整的高度,甚至在工具栏下面,因为现在它只是你布局中的一个视图。
我需要一个带操作栏的全屏应用程序。以下方法可以隐藏通知栏(包含电池、RSSI、警告等的栏)和 Navigation-bar(包含返回、首页、运行 应用程序列表)。但是Navigation-bar下的区域还是不能用。
我测试了以下帖子中的想法
- 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);
正如我所说,下面的区域Navigation-bar不可用
如果需要,您可以使用 Theme.AppCompat.Light.
并在视图层次结构中放置一个工具栏。
工具栏是操作栏的新替代品,请检查此 post:http://android-developers.blogspot.pt/2014/10/appcompat-v21-material-design-for-pre.html
这样你的布局就有了完整的高度,甚至在工具栏下面,因为现在它只是你布局中的一个视图。