I already remove the title in onCreate() method.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
}
The title is not displayed. But still appears when launching the app.
And I can use
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
or put
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
into manifest file because I'm using actionBar. If I did that, the app crashes.
So, my question is, is there any way to remove the title when the app is launching because I am gonna put a splashscreen here. Thanks.
-----------
PLEASE NOTICE:
Thanks for your answers, but I clearly said that I already used actionBar.setDisplayShowTitleEnabled(false);
to hide the title bar of the activity. (as shown in the first picture)
BUT the title bar still appears in the launching screen (as shown in the second picture.)
and
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
and
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
would lead to crash launch. This happens after I used actionbar.
I had the same problem.
Personally, I solved it by replacing my Activity inheritance from
ActionBarActivity to Activity.
Hope this will help someone...
Do this in your onCreate() method.
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
this refers to the Activity.
===========
EDIT:
if you are using ActionBarSherLock
final ActionBar bar = getSupportActionBar();
bar.setDisplayShowTitleEnabled(false);
It might be crashing because you are using this.requestWindowFeature(Window.FEATURE_NO_TITLE); after setContentView();
Use this.requestWindowFeature(Window.FEATURE_NO_TITLE); in onCreate() of your Activity , before setContentView(); statement.
May be i am repeating the same which all are saying but i just need to confirm it.In manifest file have add the theme like the below which i added as sample or anyother way.
<application ....
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:largeHeap="true"> ..
</application>
Just remove all other code related to hide title bar only andonly add this one in the manifest file it works for me.I hope it will work to you too.
Nick Butcher and Katherine Kuan wrote a nice Google Plus post about a smoother app launch experience:
https://plus.google.com/+AndroidDevelopers/posts/VVpjo7KDx4H
However, if you want to be compatible with Android versions below API 14 (for example using AppCompat), the only way I could achieve this is by using a separate launch activity using a theme with no actionbar.
Set your splashscreen as your main activity and set the theme to
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
create and intent to move your splash screen to your actual main activity
Use this:
ActionBar bar = getActionBar();
bar.hide();
or
ActionBar bar = getActionBar();
bar.setDisplayShowHomeEnabled(false);
bar.setDisplayShowTitleEnabled(false);
in res/values/styles.xml
find ...
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
replacing for.
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="windowActionBar">false</item>
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
Save and compile...
Put below three line in onCreate Method before setContentview in your activity which want to display full screen
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Hope below lines will help you
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
You can simply add full screen theme to that activity in your manifest file:
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
In your AndroidManifest.xml in application tag set your theme to full screen like in below code.
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Related
Sorry if this is a stupid question, but I'm not finding an answer anywhere.
I'm working through the beginning Android tutorials and my application icon is not showing up, even though I'm positive it is referenced correctly in my manifest file. What I'm finding online is pointing to the app icon being disabled in my current theme.
How can I forcefully enable it? This is what I tried to no avail:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:icon">#drawable/ic_launcher2</item>
</style>
Thanks in advance!
EDIT:
My OnCreate method is as follows on my main activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(true);
}
As per the Material Design guidelines, app icon is not recommended anymore on the toolbar. That's why your theme from the support library is disabling it.
Try calling:
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setLogo(R.drawable.ic_launcher);
in the onCreate method of your Activity.
I'm trying to incorporate Google's LeftNavBarLibrary into my application. When I load the nav bar I end up with a black bar across the top of the activity. The bar appears to be taking up the space a traditional actionbar would occupy.
Does anyone know where the bar is coming from or how to remove it.
Thanks.
My application theme is slightly customized. Based on the AppCompat theme due to requirements of the MediaRouteActionProvider
styles.xml
<resources>
<style name="AppTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/ab_gradient</item>
</style>
</resources>
The activity pictured above has a custom theme defined in the manifest.
AndroidManifest.xml
<activity
android:name="my.app.namespace.CoreActivity"
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
</activity>
The applications minimum sdk version is 14. So it's not exclusively a Google TV app. I've only been able to test this bug on my Android 4.1 and 4.4 devices.
I deal with the action bar this way:
getActionBar().hide();
Try to put this in your main activity or the activity that is the parent and always present.
Don't bother about the theme in manifest, just set your theme with title bar and hide it through the code.
Hope this helps.
Take a look at: Hide the Status Bar on Android 4.0 and Lower
Notice that this is in the <application> tag. That might help you.
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
or programmatically:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If the Android version is lower than Jellybean, use this call to hide
// the status bar.
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.activity_main);
}
You can set android:windowActionBar style to false by setting custom theme.
Note: In this case getActionBar() will return null. If you remove the action bar using a theme, then the window will not allow the action bar at all.
Thanks for the answers guys. The real issue was actually that the LeftNavBar.java class was creating an artificial margin at the top of the screen. I'd have thought that a google published library would be better than that, but apparently not.
I have created an Android application in Eclipse and when I have setting up I have unchecked every navigation bar. I still have the default navigation bar, how I can remove it?
You can do this in your activity:
ActionBar actionBar = getSupportActionBar(); \\ or getActionBar()
You can then hide it like this:
actionBar.hide();
Please note the warning about this in the "Removing the action bar" section of http://developer.android.com/guide/topics/ui/actionbar.html
In an app I made, I removed the title/ActionBar using this code in the onCreate method:
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main); //insert your own layout here
Make sure that the requestWindowFeature method appears before the setContentView method, because otherwise your Activity will crash.
First of all create a new theme/style within your styles.xml in the resources folder. Insert the following code within your resource tags:
<style name="noActionBar" parent="Theme.Base"></style>
By using parent "Theme.Base" it creates a blank screen to work on. Then just set your android theme to your new style in the android manifest, within the 'application' tags.
android:theme="#style/noActionBar"
Please note that if your class file for your activity contains any reference to the ActionBar it may crash when compiling.
Go in styles.xml and change to:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
I want to hide the title bar in all activities of my app. To do that, I put the following attribute in the tag:
android:theme="#android:style/Theme.NoTitleBar"
The title bar is now hidden, but my problem is that my app looks weird with that attribute.
Before:
http://imageshack.us/a/img831/6905/screenshot1355296053406.png
with the noTitleBar attribute:
http://imageshack.us/a/img211/581/screenshot1355295921669.png
It looks like there is less contrast..
It makes no difference if the noTitleBar attribute is in the application tag or in each activity tag.
Hope you can help me with my problem.
In onCreate() of activity write following:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
It's probably because you have also removed the Theme of your application together with the title bar.
I'm not sure what your theme was before, but you should extend an existing theme. Something like this in your styles file:
<style name="MyTheme" parent="android:Theme.Light.NoTitleBar.">
</style>
Maybe your parent theme should be android:Theme.Black.NoTitleBar?
You've accepted no answer so I'm going to toss my 2 cents in here:
Adding this snippet of code might be helpful:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
My android app has tab navigation using an action bar. It works well, but it bothers me that during the first boot of the app, a small default action bar briefly shows up before being replaced by the real, tab-navigation action bar. My onCreate starts like this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_main);
//Set up the actionbar
final ActionBar actionBar = getActionBar();
.
.
.
What do I have to do so that the real actionbar will be initialized without a small default one briefly showing before it does on startup?
Thanks
Hide during startup
getSupportActionBar().hide();
After you can show it again with ...
getSupportActionBar().show();
It should be the same with native ActionBar of Android.
you should use this line in manifest and don't use getActionBar()
<item name="android:windowActionBar">false</item>
and once it's finished in the main Activity use below or nothing
<item name="android:windowActionBar">true</item>
put this for your activity manifest definition:
<activity
android:name=".MyActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
>
then inside your oncreate do this to show the actual theme you want used:
setTheme(R.style.AppTheme);
if you're using action bar sherlock and you want to toggle this from a FragmentActivity, then you call
getSherlockActivity().getSupportActionBar().hide();