1. 推荐!(因为现在工程都默认的为AppTheme)
在value/styles.xml里面添加自定义属性
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
</resources>
2.
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// 隐藏标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 隐藏状态栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//一定要放在setContentView()之前!
setContentView(R.layout.activity_main);
}
}
3.
<!-- 同时隐藏状态栏和标题栏 -->
<activity
android:name="com.ysj.demo.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>
</activity>
4.打开项目文件AndroidManifest.xml ,打开Application选择TAB页,在页面下方的Application Nodes中点选择相应的类, 配置右侧的Theme属性。
在弹出选择框中点选"system Resources",选择Theme.NoTitleBar项目,然后重新打开页面就行了