首页 > 代码库 > 如何隐藏android的屏幕上的Title Bar

如何隐藏android的屏幕上的Title Bar

1. 在Activity中的onCreate方法中加入如下代码:

//Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    //Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

   //set content view AFTER ABOVE sequence (to avoid crash)
    this.setContentView(R.layout.your_layout_name_here);

2.修改AndroidManifest.xml中的activity节点的theme属性

<activity android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
3.修改AndroidManifest.xml中的application节点的theme属性
<application android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">