Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide/remove the title bar in android [duplicate]

In my code I write:

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.setContentView(R.layout.activity_main);

I've written all of it before the setContentView() call is made but it doesn't work.

I've already used the theme in android studio to remove the title bar and set the app to fullscreen but nothing changed.

How can I remove or hide the title bar that shows by default, when developing an android app?

like image 880
Twing90 Avatar asked Dec 24 '22 12:12

Twing90


2 Answers

To inherit from a predefined style definition

1. Create a new style definition in your styles.xml file and make it a child of Theme.AppCompat.Light.NoActionBar.

For example:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

2. Add the new style definition to your application tag in the AndroidManifest.xml file

<application
    ...
    android:theme="@style/AppTheme">

To specify the individual properties

Add the following properties to a new or existing style definition in the styles.xml file and ensure the style definition has been referenced in the AndroidManifest.xml file, as above:

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
like image 50
KeLiuyue Avatar answered Dec 26 '22 01:12

KeLiuyue


go to values and select styles.xml change AppTheme to

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
like image 41
Ahmad_Sbaih Avatar answered Dec 26 '22 02:12

Ahmad_Sbaih