android自带的activity主题(Theme)没有既可以全屏又带actionbar的,因此如果想要如题的效果,一是自己定义Theme,而是使用代码设定,如下举例:
方法1:自定义Style:
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Action.FullScreen" parent="@android:style/Theme.Holo">
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
方法2,需要放到setContent(int res)前面:
requestWindowFeature(Window.FEATURE_NO_TITLE); //隐藏ActionBar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置全屏