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")));
Related
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);
Navigation bar vs toolbar i am trying to change my navigation bar a little bit. I want to insert a picture inside it and change the color but leave the back button there. What is the easiest way to do it? Thanks
How can I programmaticly set the color of the action bar menu.
I am talking about the three vertical dots that appear on the top right of the action bar.
How can I set the color of this programatically.
Here is what I have tried
How do I change the background color of the ActionBar of an ActionBarActivity using XML?
How to change the background color of Action Bar's Option Menu in Android 4.2?
Thanks for the help.
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
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.