how to overlay the action bar and hide title bar also - java

I want to overlay the action bar and also hide the title bar.I have tried this
requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY );
But both is not working ,only one of the feature is working at a time.Any suggestion?

Try assigning the actionbar into a variable first... you can then use that variable to do anything you want e.g
ActionBar actionBar = getActionBar();
actionBar.hide();
For androidbar overlay create a custom android bar theme. See https://developer.android.com/training/basics/actionbar/overlaying.html

Related

How to hide the search bar in the toolbar of my Android application?

I have a search bar in the toolbar of my application. How to hide the search bar in the toolbar temporarily? I want to hide it by default and show the title of the activity in the toolbar. When I want to search, the application is able to show the search bar again. What is the solution of this situation?
You can hide the search bar by setting it to be an icon by default. It will become an icon and the title of the activity can be shown in the toolbar. Later you can expand the icon to be the search bar again by clicking the icon and change it back to an icon by clicking the cross icon in the search bar.
searchView.setIconifiedByDefault(true);
searchView.setVisibility(View.GONE);
titleac.setVisibility(View.VISIBLE);
Try
searchbar.setVisibility(View.VISIBLE);
and
searchbar.setVisibility(View.INVISIBLE);

ActionBar animation issues

I am using the ObservableScrollView library to show and hide the ActionBar as you are scrolling up and down an activity. This works well but when the ActionBar is animating sliding in or out a blank area at the bottom of the screen about the size of the ActionBar is briefly pushed up.
After searching similar issues the suggested solution is to the following line to onCreate():
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
This has had no visible effect and the issue is still present.
Solved by setting my ActionBar to overlay content in the XML style.

set onPressed color action bar programmatically

I have done some research, looked at this question but it didn't have the answers I was looking for.
Change Action Bar onPressed color.
It is doing the same thing but is not what I am looking for, as I want to set the action bar color programatically, as I need to change the color by user preference. Here is how I get the action bar
ActionBar bar = getActionBar();
Any help with setting the color for when the back button or an item in the menu is tapped would be great. Thanks :)
to change actionbar background, try this
bar.setBackgroundDrawable(new ColorDrawable(0xff00DDED));
Put this code into your oncreate method:
ActionBar actions = getActionBar();
actions.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FF3300")));

How to hide actionbar and show tabs

Many suggested that I should use:
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
and it shows me an actionbar with no title but with the application logo.
It was also suggested that I hide the logo and, when I did, the actionbar appeared empty and didn't hide.
duplicate question , see :
Android: Hide ActionBar, keep Tabs , Only display tabs in action bar
Android: How do you hide Tabs in the ActionBar?
You can hide the action bar at runtime by calling hide(). For example:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
Full documentation

Customise Actionbar how can i achive?

i want to show two images in action bar without listing in menu.xml file
means i want to customise with image button or button and i want to set background color in action bar i want to try with onCreateActionView() this method can any one provide me deep knowledge ?
design a layout as per your need and use the code
actionBar.setCustomView(R.layout.test_action);
and u can use the buttons or images by finding its id from the action bar.

Categories