In my app there is this title bar at the top where the overflow menu would be, but I don't need settings and only have one screen. When I change the theme like described in many other questions I get the old 2.2 theme. I want to have the modern theme just without the bar at the top.
31 Answers
Go to styles.xml and change .DarkActionBar
for .NoActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
becomes
<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>
if colors are irrelevant to your app, you can actually go for
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" />
-
1Works as expected. However, the title is also gone when viewing all active apps. Apr 23, 2018 at 14:58
-
how would you fix that @IAbstract ?– user9955719Jul 19, 2020 at 18:45
-
In the manifest file Change:
android:theme="@style/AppTheme" >
android:theme="@style/Theme.AppCompat.NoActionBar"
-
4While this works, editing the
styles.xml
file might be a better option for most, as using this method ignores any values which may have been set up underAppTheme
in thestyles.xml
file. The solution below which replaces the parent class withNoActionBar
within thestyles.xml
file preserves any pre-existing style information which has been set up. Jun 1, 2016 at 17:32 -
-
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
works in onCreate()
when put before setContentView()
is invoked.
otherwise it crashes
-
7This causes app to crash. I put the line in between
super.onCreate.....
andsetContentView.....
And it crashes– NalorinNov 23, 2015 at 4:44 -
This is not the correct way to do it. Mr. Torres explained it well. Jan 10, 2018 at 14:47
Check this
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
-
This is working code to hide the bar by a program itself. Could be placed in constructor
onCreate(...)
after thesuper.onCreate(..)
andsetContentView(...)
lines to hide bar just after program is started. Apr 27, 2017 at 9:52
In styles.xml file, change DarkActionBar to NoActionBar
<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>
Go to Project -> app -> main -> res -> values -> styles.xml
Change this line if you want to delete it for every view
`<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">`
to
`<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">`
if you want to make it just for one view you can change it in youre manifest data. Go to Android -> manifests -> AndroidManifest.xml. do following:
- Search the View you want to get this type of change
<activity android:name"...">
- Add
android:theme=""@style/Theme.AppCompat.NoActionBar"
-
I like this solution. Unlike setting NoActionBar in the manifest which forces you to remove any already applied theme (or style) e.g. Theme.MyApp, with this solution one can edit Theme.MyApp and preserve few customization. Nov 18, 2020 at 8:07
This was working for me on values/styles.xml
add items:
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
In the manifest file change to this:
android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
- open styles.xml
- insert
<style name="no_title" parent="AppTheme"> <item name="android:windowNoTitle">true</item> <item name="android:windowContentOverlay">@null</item> </style>
you can change name="---------"
open Androidmaifest.xm
find android:theme="@style/AppTheme" chang to android:theme="@style/no_title"
click select Theme on menubar (it's green color near MainActivity)
- click project Theme
- click no_title (on you right hand Side)
- click OK
For Beginner Like Me. Just Do it what I say.From your Android Project.
app -> res -> values -> style.xml
replace this code
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Enjoy.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
Just simply put getSupportActionBar().hide();
between super.onCreate
and setContentView
method.
do this in you manifest file:
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
-
it switches me to the old android design (black background, textboxes with yellow borders...)– JonasOct 22, 2014 at 7:03
-
try
android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
make sure you are using api level min 14.– RustamOct 22, 2014 at 7:08 -
You can use this for a light theme: android:theme="@style/Theme.AppCompat.Light.NoActionBar" >– XIIIAug 28, 2015 at 12:56
delete the following from activity_main.xml
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
Newer versions replaced styles.xml with themes.xml
Go to Project -> app -> res -> values -> themes -> themes.xml
and change e.g.
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- omitted for brevity -->
</style>
to
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- omitted for brevity. -->
</style>
Switching the parent to NoActionBar
Do this for both themes.xml files
Try changing styles to NoActionBar if that doesn't works add this code to your main activity
protected void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
setContentView(R.layout.activity_main);
}
This works for me i hope this work for you as well
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
In Kotlin, this is how to do.
val actionBar: ActionBar? = supportActionBar
actionBar?.hide()
Best way is to use actionbar function setTitle()
if you wish to show logo or have some other stuff in you actionBar but dont want to see name of the app, write this code in MainActivity.java or anywhere you wish to hide title in onCreate
:
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setIcon(R.mipmap.full_white_logo_m); // display logo
actionBar.setTitle(""); // hide title
This way your app won't have reason to crash.
Just use setTitle(null)
above
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
The title will disappear then you can use the logo of your choice.....
I have faced the same problem as you, and solve this problem just by changing the class which I extended.
//you will get the app that does not have a title bar at the top.
import android.app.Activity;
public class MainActivity extends Activity
{}
//you will get the app that has title bar at top
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity
{}
I hope this will solve your problem.
In AndroidManifest.xml
of your application you'll find the android:theme
for example set to @style/AppTheme
Now go to styles.xml
, find the style tag, make sure that name is set to AppTheme
the same as in manifest and set parent to android:Theme.Holo.Light.NoActionBar
(also do this in styles(v21) if you have it in your project)
<style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar">
<!-- ... -->
</style>
try: toolbar.setTitle(" ");
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("");
setSupportActionBar(toolbar);
}
-
Welcome to Stack Overflow! Please don't answer just with source code. Try to provide a nice description about how your solution works. See: How do I write a good answer?. Thanks Sep 18, 2018 at 7:22
To simply remove the title bar (which means the bar contains your app name) from an activity, I simply add below line to that activity in the manifests\AndroidManifest.xml
:
android:theme="@style/AppTheme.NoActionBar"
It should now look like below
<activity
android:name=".MyActivity"
android:theme="@style/AppTheme.NoActionBar"></activity>
Hope it'll be useful.
At Project tab, find
app>res >values > themes >theme.xml
-
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.– Community BotDec 16, 2022 at 11:56
New versions of Android Studio have themes.xml
instead of styles.xml
. So go to res/values/themems/themes.xml
and change .DarkActionBar
to .NoActionBar
-
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.– Community BotNov 7, 2022 at 6:29
This also solved my problem, but before it did I couldn't find the styles.xml resource.
Eventually I found a solution and it turns out that the theme attribute is now inside the themes.xml not the styles.xml Here is my example