原文请点击这里
第一种,在调用setContentView()之前插入代码:
requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
setContentView(R.layout.activity_main);
第二种,在AndroidManifest.xml文件中配置Activity:
<activity android:name="com.example.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
第三种,修改res/value/style.xml文件,增加一个样式,然后在相应的activity中应用该样式:
<!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <item name="android:windowNoTitle">true</item> </style>
定义完了一个style,接下来就是在AndroidManifest.xml中使用了:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/AppTheme">