How disable / remove android activity label and label bar?
AndroidAndroid Problem Overview
Is there anyway to remove activity label bar and label itself which is set by default from application label? I'd like to have whole layout from my design and need to remove the label bar and label which is in TOP layout.
Android Solutions
Solution 1 - Android
You can achieve this by setting the android:theme
attribute to @android:style/Theme.NoTitleBar
on your <activity>
element in your AndroidManifest.xml like this:
<activity android:name=".Activity"
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>
Solution 2 - Android
If your application theme is AppTheme(or anything else), then in styles.xml add the following code:
<style name="HiddenTitleTheme" parent="AppTheme">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
Then in manifest file add the following in the activity tag for which you want to disable activity label:
android:theme="@style/HiddenTitleTheme"
Solution 3 - Android
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//set up notitle
requestWindowFeature(Window.FEATURE_NO_TITLE);
//set up full screen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
Solution 4 - Android
I am not 100% sure this is what you want but if you are referring to the title bar (the little gray strip at the top), you can remove/customize it via your manifest.xml file...
<activity android:name=".activities.Main"
android:theme="@android:style/Theme.NoTitleBar">
Solution 5 - Android
you can try this
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
Solution 6 - Android
You have two ways to hide the title bar by hiding it in a specific activity or hiding it on all of the activity in your app.
You can achieve this by create a custom theme in your styles.xml
.
<resources>
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
If you are using AppCompatActivity, there is a bunch of themes that android provides nowadays. And if you choose a theme that has .NoActionBar
or .NoTitleBar
. It will disable you action bar for your theme.
After setting up a custom theme, you might want to use the theme in you activity/activities. Go to manifest and choose the activity that you want to set the theme on.
SPECIFIC ACTIVITY
AndroidManifest.xml
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<activity android:name=".FirstActivity"
android:label="@string/app_name"
android:theme="@style/MyTheme">
</activity>
</application>
Notice that I have set the FirstActivity
theme to the custom theme MyTheme
. This way the theme will only be affected on certain activity. If you don't want to hide toolbar for all your activity then try this approach.
The second approach is where you set the theme to all of your activity.
ALL ACTIVITY
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme">
<activity android:name=".FirstActivity"
android:label="@string/app_name">
</activity>
</application>
Notice that I have set the application theme to the custom theme MyTheme. This way the theme will only be affected on all of activity. If you want to hide toolbar for all your activity then try this approach instead.
Solution 7 - Android
Solution 8 - Android
There's also a drop down menu in the graphical layout window of eclipse. some of the themes in this menu will have ".NoTitleBar" at the end. any of these will do trick.
Solution 9 - Android
In my case, the others answers was not enough...
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
Tested on Android 4.0.3 API 15.
Solution 10 - Android
Whenever I do rake run:android,
my Androidmenifest.xml file is built-up again so my changes done
for NoTitlebar no more persist.
Rather than user adroid_title: 0
This helped me.
edit your build.yml
android: android_title: 0 #rest of things #you needed
Solution 11 - Android
This one.
android:theme="@style/android:Theme.NoTitleBar"
Solution 12 - Android
you can use this in your activity tag in AndroidManifest.xml to hide label
android:label=""
Solution 13 - Android
IF you are using Android Studio 3+ This will work: android:theme="@style/Theme.AppCompat.NoActionBar"
@android:style/Theme.NoTitleBar will not support in new API and force you app close.
Solution 14 - Android
with your toolbar you can solve that problem. use setTitle method.
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setTitle("");
setSupportActionBar(mToolbar);
super easy :)