-3

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!

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
Freddy Le
  • 3
  • 3

2 Answers2

1

Into onCreate() add:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

Ahmad Sanie
  • 3,678
  • 2
  • 21
  • 56
  • Thanks, i tried that but its still not working. I get the following in my console: [2014-12-28 20:11:05 - Elevel] Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE [2014-12-28 20:11:05 - Elevel] Please check logcat output for more details. [2014-12-28 20:11:05 - Elevel] Launch canceled! – Freddy Le Dec 29 '14 at 02:12
  • does the application works then crashes or it doesn't work at all? – Ahmad Sanie Dec 29 '14 at 02:14
  • It doesnt launch anymore – Freddy Le Dec 29 '14 at 02:18
  • add the android:installLocation attribute to your application's manifest file, with the value "preferExternal". – Ahmad Sanie Dec 29 '14 at 02:30
  • The app is launching now but it still crashs. I took a screenshot of the LogCat: http://i.stack.imgur.com/WMKyw.png – Freddy Le Dec 29 '14 at 02:41
  • try to set feature before super – Ahmad Sanie Dec 29 '14 at 03:00
  • if that didn't work use: getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); //another alternative is leverage AsyncTask for dialogs search for it if non of the prev method worked !! – Ahmad Sanie Dec 29 '14 at 03:04
  • Well at least the app is launching now but the title bar is still there. I put the requestWindowFeature(Window.FEATURE_NO_TITLE); before super and added this to my themestyle: – Freddy Le Dec 29 '14 at 04:04
0

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!

gsanskar
  • 673
  • 5
  • 10