一、如果MainActivity 继承自 Activity,用requestWindowFeature(Window.FEATURE_NO_TITLE)来隐藏:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 隐藏标题栏。注意防止setContentView()之前
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
:
:
二、如果MainActivity 继承自 AppCompatActivity,用getSupportActionBar().hide()来隐藏:
@Override
protected voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 隐藏标题栏。注意防止setContentView()之前
if(getSupportActionBar() !=null){
getSupportActionBar().hide();
}
setContentView(R.layout.activity_main);
:
: