方法1
在OnCreate函数里面加入如下代码注意一定要在setContentView前面:
super.onCreate(savedInstanceState);
// 隐藏标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 隐藏状态栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
方法2
在manifest.xml里面更改以下内容:
这个方法容易让app崩溃特别是在启动函数里面设置成这个theme主题的时候
<activity
android:name="com.ysj.demo.MainActivity"
//主题theme设置成没有title并且全屏显示的,这个时候在eclipse里面会显示成黑色的底色,需要在drawable里面加入背景.xml文件(用shape)
//并且这个方法容易让app崩溃
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>
</activity>