I can not remove the title bar of the android application [duplicate]

0

I have tried using android:theme="@android:style/Theme.NoTitleBar" , but when I run my app it gives error.

    
asked by anonymous 08.02.2015 / 04:04

2 answers

4

We have many ways to do this. One of them is by code, just add the following line in the onCreate method:

requestWindowFeature(Window.FEATURE_NO_TITLE);

Looking like this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
}

You can also remove the title bar from the file " AndroidManifest.xml ". For this we must modify the declaration of the Activity to declare that we do not want the bar. Just add / modify the " android:theme " attribute in the Activity declaration, like this:

<activity android:theme="@android:style/Theme.Black.NoTitleBar">

In order for all Activities of your application to be without the title bar, modify the same attribute, but in the "Application":

<application android:theme="@android:style/Theme.Black.NoTitleBar">

With the complexity of the applications we develop today, it is not uncommon to work with themes, which greatly facilitates our work. If you already work like this and do not want to be adding the removal codes in all your classes, just modify your theme and put the attribute " android:windowsNoTitle " as true .

See the example:

<resources>
  <style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
    <item name="android:windowNoTitle">true</item>
  </style>
</resources>

Source: link

I hope I have helped.

    
08.02.2015 / 04:41
0

It's simple, just add a line of code to onCreate.

@Override 
protected void onCreate(Bundle savedInstanceState) {          
    super.onCreate(savedInstanceState);
    getSupportActionBar().hide(); //Esta linha contém o código necessário.
    setContentView(R.layout.sua_activity);
}
    
03.07.2017 / 22:25