Search code examples
javaandroideclipsetitlebar

Eclipse Android remove titlebar


I am trying below code to remove title bar:

super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);

But the title bar still appears.

I also tried android:theme="@android:style/Theme.Black.NoTitleBar" but that crashs the app

Thanks for help!


Solution

  • You have to put one more line of code below your requestWindowFeature(Window.FEATURE_NO_TITLE);

    So here goes the complete code for onCreate till setContentView :

    @Override
    public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
    -------
    -------
    }
    

    Hope this helps!