How to remove Titlebar?

3.7k Views Asked by At

I am trying to remove title bar from my activity but it is not getting removed.

Here is my code

public class SplashScreen extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_splash_screen);


    }
}

With or without the requestWindow line the output is the same then what is the use of that line?

4

There are 4 best solutions below

1
On

I would reccomend editing your theme with no title bar. For example use of of these...

<style name="Theme.NoTitle" parent="@android:style/Theme.NoTitleBar"></style>
<style name="Theme.FullScreen" 
parent="@android:style/Theme.NoTitleBar.Fullscreen"></style>
0
On

Apply this theme in your activity declared in the Manifest File.

<activity
    android:name=".SplashScreenActivity"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar">
</activity>
0
On

Can you try adding this to your manifest inside activity tag :

<activity
        android:name="your_app_packagename.activity_name"
        android:theme="@android:style/Theme.NoTitleBar" >

also try this in your activity :

ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
1
On

Add this in onCreate

   getSupportActionBar().setDisplayShowTitleEnabled(false);
   getSupportActionBar().setDisplayShowHomeEnabled(false);