设置全屏的俩段代码必须在setContentView(R.layout.main) 之前,不然会报错。
标题栏
1、第一种方法最为常见:
--效果不是很好!--
requestWindowFeature(Window.FEATURE_NO_TITLE);
//
去掉标题栏
2、在清单中设置
效果不错--不会出现标题栏闪一下的情况
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">......
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">......
3、
这种在一般的应用中不常用,就是在res/values目录下面新建一个style.xml的文件
该方法与方法二有点相识!
效果不错--不会出现标题栏闪一下的情况
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<stylename="notitle">
<itemname="android:windowNoTitle">true</item>
</style>
</resources>
<resources>
<stylename="notitle">
<itemname="android:windowNoTitle">true</item>
</style>
</resources>
这样,我们就自定义了一个style,就相当于一个主题,然后在AndroidManifest.xml文件中定义
<applicationandroid:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/notitle">
android:label="@string/app_name"
android:theme="@style/notitle">
标题栏隐藏有时也要隐藏状态栏
1、在代码中书写
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
2、在清单中设置
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
3、与方法二类似
--此方法有瑕疵!--标题栏依然存在
<style name="fullscreen">
<item name="android:windowFullscreen">true</item>
</style>
<item name="android:windowFullscreen">true</item>
</style>
applicationandroid:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/fullscreen"
android:label="@string/app_name"
android:theme="@style/fullscreen"