Kinoscorpia
Kinoscorpia

Reputation: 478

Android: How to remove the Activity Title Bar?

I am wanting to get rid of the Activity Title Bar as it is annoying to have. However, I do not want to have a fullscreen activity.I have tried just adding @android:style/Theme.NoTitleBar to activity and android:theme="@android:style/Theme.NoTitleBar.Fullscreen to the manifest file, but I keep getting the error: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. Nothing seems to help.

Upvotes: 0

Views: 1587

Answers (5)

windupurnomo
windupurnomo

Reputation: 1190

You can extend Activity instead of AppCompatActivity and use the following code:

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

    // remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    // remove notification bar 
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_splash);
}

Upvotes: 1

ygesher
ygesher

Reputation: 1161

Simplest way to go:

getActionBar().hide();

put it in your onCreate method and you'll never see the Action Bar.

Upvotes: 0

Kirill Shalnov
Kirill Shalnov

Reputation: 2216

If it asked you use Appcompat theme - use appcompat theme

Theme.AppCompat.Light.NoActionBar

Upvotes: 1

user4346621
user4346621

Reputation:

Do this in onCreate

    //Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

In your style.xml

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

Hope it helps

Upvotes: 0

rscnt
rscnt

Reputation: 1005

It's possible to set flags to an activty window:

For example you can achieve your propose writing this on the onCreate method of your activity.

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

Upvotes: 0

Related Questions