How to hide the title bar for an Activity in XML with existing custom theme

前端 未结 30 2057
误落风尘
误落风尘 2020-11-22 03:28

I want to hide the titlebar for some of my activities. The problem is that I applied a style to all my activities, therefore I can\'t simply set the theme to @android:

30条回答
  •  Happy的楠姐
    2020-11-22 03:43

    Do this in your onCreate() method.

    //Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    
    //Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
    //set content view AFTER ABOVE sequence (to avoid crash)
    this.setContentView(R.layout.your_layout_name_here); 
    

    this refers to the Activity.

提交回复
热议问题