android 标题栏,状态栏的显示和隐藏

Android 4.0

android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"  方式二:代码(状态栏和标题栏隐藏)
在onCreate()方法中,加上下面两句,不过要放在 setContentView(R.layout.activity_main); 之前 
// 去除title
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 去掉Activity上面的状态栏    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
方式三:自己写(隐藏显示状态栏,标题栏不能隐藏)
/**
 * 状态栏显示和隐藏
 * 
 * @param enable
 *            true为隐藏,false为显示
 */
private void full(boolean enable) {
    if (enable) {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        getWindow().setAttributes(lp);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    } else {
        WindowManager.LayoutParams attr = getWindow().getAttributes();
        attr.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().setAttributes(attr);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
}
自定义标题栏