Removing Titlebar from the android app

Asked

Viewed 18,836 times

7

I’m starting on android, and know very little! I’m developing slowly and with each change I save the apk and see it running on my phone. I noticed that there is a bar in the app with the name of the application! I would like to take this bar! I saw several tutorials on the internet, but none worked! I don’t know if I’m actually doing it wrong or if it has to do with compatibility!

I use Android Studio and in Theme I put "Notitlebar", but it does not work!

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="proj.beta" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/logo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

The Title_bar I refer to is in the following image!

inserir a descrição da imagem aqui

  • You really want to completely remove the bar or just the title?

  • Is Titlebar or actionBar?

  • @Mateuscarvalho is the same Titlebar, actionBar is where the clock is and the other icons, is not?

  • @regmoraes I want to remove completely

6 answers

9


You can configure by Manifest to leave the app on fullscreen.

Androidmanifest.xml

<application
    android:allowBackup="true"
    android:icon="@mipmap/logo"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar">

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Via Java code

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

// setContentView()
  • I did what you said, only the app didn’t even run! Gave an error message saying it stopped working

  • Right, send me your manifest without the code above.

  • Okay. I’ll put it in the question

  • I edited the answer.

  • First the code I left in the reply, and then you put the setContentView.

  • in fact the app worked on full screen, but the bar of TITLE_BAR continues to show. The only thing missing was action_bar

  • 1

    Send an image describing your problem, say the "title_bar" you want to remove.

  • @ivanveloso, see my answer again. Take the code from the "Androidmanifest.xml" part and swap in your code.

  • If you prefer, just change the line: android:theme="@android:style/Theme.NoTitleBar">

Show 5 more comments

6

Friend is bearded, go on res/values/styles.xml

modify parent="Theme.AppCompat.Light.DarkActionBar" for parent="Theme.AppCompat.Light.NoActionBar" and do a rebuild and just emulate.

2

Simple, just add a line to the 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);
}

1

You can in the method onCreate() of its Activity

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

1

In your file styles.xml comes with a default theme:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
</style>

To remove the ActionBar, create a style with the same parent of the default style, including only the NoActionBar:

  <style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">

    </style>

In Activity you wanted to remove Actionbar, add the theme:

  <activity
        android:name=".MainActivity"
        android:theme="@style/AppThemeNoActionBar" >

0

Try to change the theme of your Activity to:

android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"

Att. Jeiferson

Browser other questions tagged

You are not signed in. Login or sign up in order to post.