Android Activity设置全屏显示

代码中设置

1
2
3
4
5
requestWindowFeature(Window.FEATURE_NO_TITLE); //隐藏标题
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); //设置全屏

setContentView(R.layout.activity_main);

注意:setContentView一定要写在设置全屏后边

AndroidManifest.xml文件中设置

1
2
3
4
5
6
<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

1
2
3
4
5
6
7
<!-- 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>

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :