方法一:
在Activity中,setContentView前添加
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
注意:當類extends AppCompatActivity時,該方法無效。
方法二:
在Activity中,setContentView前添加
getSupportActionBar().hide();
問題:本人在使用這個方法去除標題欄時,在某種情況下,會去除無效。因此,有了第三種方法。
方法三:
在style.xml中設置
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
在AndroidManifest.xml中引用
android:theme="@style/AppTheme.NoActionBar"