What is the difference between Activity Title and Action Bar Title. Both seem to occupy same area
however activity title is set using
getActivity().setTitle("abc")
and Action Bar Title by
getActivity().getActionBar().setTitle("abc")
Well, there is a difference,
When setting the action bar's title using the setTitle method of class ActionBar will only be displayed if DISPLAY_SHOW_TITLE is set or action bar is present in the activity.
However, the setTitle method of Activity class can be used to set title even when there isn't any action bar for that window.
This really makes a difference when you are using a screen readers such as Talkback or developing an app for users with disabilities. It simply makes your app more accessible.
There is no difference.you can set title using both calls. getActivity().setTitle() is use full to set title in all devices(all API levels)
getActionBar() Call requires API level 11,and its will set action bar text
setTitle() sets Title bar text
Related
With reference to question raised at SO link :
Hide application launcher icon in title bar when activity starts in android
What should I do if I don't want to use even a logo ?
What should I do if I don't want to use even a logo ?
You can use Toolbar instead of old ActionBar. Here's a great and quick tutorial for Toolbar implementation.
Is it possible to remove title bar which I think is ugly and doesn't fit in my application but still use actionbar? After I call
requestWindowFeature(Window.FEATURE_NO_TITLE | Window.FEATURE_ACTION_BAR);
the title bar stays but piece of my view is gone(cant scroll up)
Is it possible to get rid of title bar but still keep actionbar, if I dont request it as window feature getActionBar() returns null everytime..
Following Honeycomb, Action Bar was introduced to provide more functionalities, Well you can hide logo and title from it using this
ActionBar ab = getActionBar();
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayShowHomeEnabled(false);
Is it possible to use fragment tabs on action bar with the Theme.Holo.NoActionBar theme?
I mean... I already use this theme on my layouts but apparently it is overriden since the fragments have to show up in the action bar?
What I wanted to achieve is to actually get rid of the Title and App Icon over the fragment tabs. Something similar to the Google Music app.
Is this possible?
What I wanted to achieve is to actually get rid of the Title and App Icon over the fragment tabs. Something similar to the Google Music app.
Try calling setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar, and leave the theme alone.
You can style the action bar based on your needs. I'm quite certain you can also remove the app icon and title from there. Using a NoActionbar theme by default and then recreating the action bar on your own kinda defeats the purpose of the action bar. I suggest you use a theme with action bar and then style the bar according to your needs. This page has a decent implementation.
How do you remove the category bar that displays in the PreferenceScreen? I have my own custom view for that, so I want to get rid of it altogether.
Would this help? Android – Hidding the status and title bar of your application
So I am setting a custom title bar for all of my activities using the following code in the onCreate.
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(id);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
activityTitle = (TextView)findViewById(R.id.titleText);
if (activityTitle != null)
{
activityTitle.setText(title);
}
This sets the custom title bar correctly but I find that on the main launcher activity the name of the app shows in the title bar for a split second then changes to the title I set above. This only happens for the main entry point activity, all other activities show my custom title instantly. Any ideas why this would happen and how to fix?
Thanks
If you're saying that the default bar shows for a brief period of time before being replaced by your custom bar, you may be experiencing the same issue as here: Android: Custom Title Bar
The workaround there is to create a style that effectively hides the default title until your custom title is displayed. You may still get pop-in, but at least it won't be showing the wrong text.