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

前端 未结 30 1682
误落风尘
误落风尘 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条回答
  •  遇见更好的自我
    2020-11-22 03:50

    I found two reasons why this error might occur.

    One. The Window flags are set already set inside super.onCreate(savedInstanceState); in which case you may want to use the following order of commands:

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);      
    
    super.onCreate(savedInstanceState);
    

    Two. You have the Back/Up button inside the TitleBar, meaning that the current activity is a hierarchical child of another activity, in which case you might want to comment out or remove this line of code from inside the onCreate method.

    getActionBar().setDisplayHomeAsUpEnabled(true);
    

提交回复
热议问题