去掉标题栏:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
去掉信息栏:
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
必须要在setContentView(R.layout.main)方法之前设置。
另外一种方法就是在配置文件里修改(android:theme="@android:style/Theme.NoTitleBar.Fullscreen"):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.layouttest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.layouttest.MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
</manifest>
第一种方法会看到短暂的状态栏,然后才全屏,而这种方法是不会有这种情况的。