代码中设置
requestWindowFeature(Window.FEATURE_NO_TITLE); //隐藏标题
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); //设置全屏
setContentView(R.layout.activity_main);
注意:setContentView一定要写在设置全屏后边
AndroidManifest.xml文件中设置
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="com.scwindow.utility.CrashApplication">
在styles.xml文件中定义主题AppTheme
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>