1. 在Activity的onCreate()方法中实现,注意要写在setContentView()前面,否则会报错。
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
2. 在AndroidManifest.xml中实现,这样会把整个应用所有界面设置为无标题栏。
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
若只是针对某一个Activity设置无标题栏,则只需要把上面第三行代码写到某一个Activity之中,如下:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme