如果你是使用旧版ActionBarActivity,只需要在onCreate方法中补充一条requestWindowFeature(Window.FEATURE_NO_TITLE);语句就可以解决问题;
如果你是用较新的AppCompatActivity 的也就是5.0以上版本以上,再根据这个requestWindowFeature(Window.FEATURE_NO_TITLE)去掉标题已不再适用;
网上有各种说法:
1、在setContentView前加上如下代码
requestWindowFeature(Window.FEATURE_NO_TITLE);(验证过该方法无效)
2、在super.onCreate(savedInstanceState)
前或后添加supportRequestWindowFeature(Window.FEATURE_NO_TITLE);(验证过该方法无效)
3、getSupportActionBar().hide();(该方法没有验证过,有需要的朋友可以自己试试);
4、在AndroidManifest.xml对应activity主题改为@android:style/Theme.NoTitleBar,如:
(该方法亲测有效实用);<activity android:name=".CustCompat" android:label="@string/app_name" android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:screenOrientation="portrait"> </activity>