I have a problem with a background color of my action menu items. As you can see below I tried to set the same background color as for the toolbar. But they are still different. I use different attributes -- background and itemBackground -- but they both don't work.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/BackgroundToolbarGrey"
android:contentInsetEnd="0dp"
android:contentInsetStart="0dp"
android:itemBackground= "#color/BackgroundToolbarGrey">
<android.support.v7.widget.ActionMenuView
android:id="#+id/mainMenu"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="left"
android:background="#color/BackgroundToolbarGrey"
android:itemBackground= "#color/BackgroundToolbarGrey"/>
</android.support.v7.widget.Toolbar>
And this is my menu.xml file where I also tried to set color:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MyActivity"
android:background = "#color/BackgroundToolbarGrey">
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:orderInCategory="100"
app:showAsAction="never"
android:background = "#color/BackgroundToolbarGrey"
android:itemBackground= "#color/BackgroundToolbarGrey">
</item>
</menu>
I also tried to set it programmatically, but it doesn't help
mainMenu= (ActionMenuView) findViewById(R.id.mainMenu);
mainMenu.setBackgroundColor(getResources().getColor(R.color.BackgroundToolbarGrey));
What can I do wrong?
You should set a PopupTheme for your ActionMenuView.
java code
mActionMenuView = (ActionMenuView) findViewById(R.id.action_menu_view);
mActionMenuView.setPopupTheme(R.style.OverFlowMenuTheme);
style.xml
<style name="OverFlowMenuTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:itemBackground">#android:color/white</item>
<item name="android:textColorPrimary">#android:color/black</item>
<item name="overlapAnchor">false</item>
</style>
Try setting the menu item's properties in onCreateOptionsMenu.
Something like this:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
View mainMenu = menu.findViewById(R.id.mainMenu);
mainMenu.setBackgroundColor(getResources().getColor(R.color.BackgroundToolbarGrey));
return true;
}
Related
I try to add menu in toolbar.i wrote some code but i have very strange situation.i can't see menu image right side in my toolbar,but when i click it(i mean right side in toolbar)menu is showing
this is a my source
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.unipay.business.activities.MainActivity">
<item
android:id="#+id/transaction_all"
android:orderInCategory="100"
android:title="#string/history_all"
app:showAsAction="never" />
<item
android:id="#+id/transaction_Income"
android:orderInCategory="100"
android:title="#string/history_income"
app:showAsAction="never" />
<item
android:id="#+id/transaction_Outcome"
android:orderInCategory="100"
android:title="#string/u_history_outcome"
app:showAsAction="never" />
<item
android:id="#+id/transaction_advanced_search"
android:orderInCategory="100"
android:title="#string/u_history_advance"
app:showAsAction="never" />
i ty to create like this menu
this is a my custom Toolbar layout xml code
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/u_common_header_height"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ToolbarTheme"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:titleTextAppearance="#style/Toolbar.TitleText">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/u_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/u_sign_open_menu_margin"
android:padding="#dimen/u_sign_open_menu_margin"
android:src="#mipmap/ic_arrow_back_white" />
<ImageView
android:id="#+id/logo_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#mipmap/logo_header"
android:visibility="gone" />
<TextView
android:id="#+id/header_tittle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="72dp"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="#dimen/u_common_text_size" />
</RelativeLayout>
I initialized my toolbar like this
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
this is a toolbar style
<style name="ToolbarTheme" parent="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<!-- android:textColorPrimary is the color of the title text in the Toolbar -->
<item name="android:textColorPrimary">#android:color/holo_blue_light</item>
<!-- actionMenuTextColor is the color of the text of action (menu) items -->
<item name="actionMenuTextColor">#android:color/holo_green_light</item>
<!-- Tints the input fields like checkboxes and text fields -->
<item name="colorAccent">#color/colorPrimary</item>
<!-- Applies to views in their normal state. -->
<item name="colorControlNormal">#color/colorPrimary</item>
<item name="colorControlActivated">#color/colorPrimary</item>
<item name="colorControlHighlight">#color/colorPrimary</item>
</style>
<style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">21sp</item>
<item name="android:textStyle">italic</item>
</style>
can anyone tell me what i'm doing wrong? as i said menu working in toolbar but i can't see menu image
thanks
try this
import android.support.v7.view.menu.MenuBuilder;
#SuppressLint("RestrictedApi")
#Override
public boolean onCreateOptionsMenu(Menu menu) {
if (menu instanceof MenuBuilder) {
((MenuBuilder) menu).setOptionalIconsVisible(true);
}
getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}
app:showAsAction="never"
change to
app:showAsAction="always" or "ifRoom"
I have recycler view + viewpager + toolbar in my activity. When I long click on the row in recycler view it should show me a menu bar with a delete option. But this is what I get. Any ideas as to why it is coming above my application name?
This is the xml of my main activity:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.kaad.sampleproject.MainActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/main_activity_tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="#+id/main_activity_tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/main_activity_tool_bar"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:tabIndicatorColor="#ff00ff"
app:tabMode="fixed"
app:tabSelectedTextColor="#ffffff"
app:tabTextColor="#d3d3d3" />
<android.support.v4.view.ViewPager
android:id="#+id/main_activity_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/main_activity_tablayout" />
</RelativeLayout>
I kept an add and about menu which never gets displayed for some reason:
Here is the xml of both my menus:
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/menu_bar_main"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
tools:context=".MainActivity">
<item
android:id="#+id/menu_item_new"
android:icon="#drawable/ic_add_white_36dp"
android:title="#string/menu_new"
app:showAsAction="ifRoom|withText" />
<item
android:id="#+id/menu_item_about"
android:title="#string/menu_about"
app:showAsAction="never" />
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/menu_bar_delete"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
tools:context=".MainActivity">
<item android:id="#+id/menu_item_delete"
android:icon="#android:drawable/ic_menu_delete"
android:title="#string/delete" />
</menu>
The xml of my styles
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!--<item name="colorPrimary">#FF595951</item>-->
<!--<item name="colorPrimaryDark">#FF5C5C5C</item>-->
<!--<item name="colorAccent">#FFCCCCCC</item>-->
<!--<item name="android:textColorPrimary">#FF0FF0</item>-->
<item name="windowActionBar">true</item>
<item name="windowNoTitle">true</item>
</style>
This is Main Activity:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_main);
database = new Database(this);
categories = database.getCategories();
myToolbar = (Toolbar) findViewById(R.id.main_activity_tool_bar);
setSupportActionBar(myToolbar);
// Get the ViewPager and set it's PagerAdapter so that it can display items
myViewPager = (ViewPager) findViewById(R.id.main_activity_viewpager);
myPagerAdapter = new MyPagerAdapter(getSupportFragmentManager(), MyMainActivity.this, categories);
myViewPager.setAdapter(myPagerAdapter);
// Give the TabLayout the ViewPager
myTabLayout = (TabLayout) findViewById(R.id.main_activity_tablayout);
myTabLayout.setupWithViewPager(myViewPager);
// Iterate over all tabs and set the custom view
for (int i = 0; i < myTabLayout.getTabCount(); i++) {
TabLayout.Tab myTab = myTabLayout.getTabAt(i);
myTab.setCustomView(myPagerAdapter.getTabView(i));
}
bus.getInstance().register(this);
}
This is how I am calling my menu bar in my main prescription fragment
public class CustomMultiSelectorCallback extends ModalMultiSelectorCallback {
private int count;
public CustomMultiSelectorCallback(MultiSelector multiSelector) {
super(multiSelector);
}
#Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
super.onCreateActionMode(actionMode, menu);
count = 0;
actionMode.getMenuInflater().inflate(R.menu.list_item_delete, menu);
return true;
}
Issue for About button:
<item
android:id="#+id/menu_item_about"
android:title="#string/menu_about"
app:showAsAction="never" />
update the never part to "ifRoom"
Regarding the menu appearing, can you be more explicit, as to me it seems in Relative Layout you wanted the Toolbar to be top and the views to come after it and that is what it shows.
So I have solved one of the problems. This is what I edited in my code to display add and about buttons in the toolbar.
First, in your onCreate in the fragments, add this line:
setHasOptionsMenu(true);
Second, in your styles, change your theme to something which has NoActionBar. In my case I did this:
<style name="AppThemeOfStyles"parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#FF595951</item>
<item name="colorPrimaryDark">#FF5C5C5C</item>
<item name="colorAccent">#FFCCCCCC</item>
<item name="android:textColorPrimary">#FF0FF0</item>
<item name="windowActionBar">true</item>
<item name="windowNoTitle">true</item>
</style>
I also changed the name of my theme from AppTheme to AppTheme of styles since AppTheme is already a theme defined. So better to change your theme name to something else.
This leads us to the result below:
But my delete is still coming on the top of the toolbar on longpress.
Any suggestions, advice will be appreciated :)
UPDATED:
Use this in your theme for the overlay to work:
<item name="windowActionModeOverlay">true</item>
Here is the end result:
I want to use android v7.toolbar in my project with fragments. So i did something like below in my main activity xml. Because i dont want to add all fragments xml to android.support.v7.widget.Toolbar
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="#+id/toolBar" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/fragment_container">
</FrameLayout>
</LinearLayout>
i am adding fragments with programmatically. And in some fragments i have to change right side of the toolbar. For example in some fragments i have to use just 1 right menu icon and another fragments 2. How can i achieve it?
Also is there a way to change icon resource which is in right side of the toolbar from fragments?
Thanks,
You can create menu.xml and put all your menu items in it. Set all the items visibility to false. This hides everything.
Then in your fragment's onCreate set setHasOptionsMenu(true), this will allow you to override onCreateOptionsMenu(Menu m, MenuInflater inflater).
In this method you can do menu.findItem(id.of.item).setVisible(true/false).
Examples:
menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.sample.app.MainActivity">
<item
android:id="#+id/action_refresh"
android:icon="#drawable/ic_action_refresh"
android:orderInCategory="101"
app:showAsAction="ifRoom"
android:title="#string/action_refresh"
android:visible="false"/>
<item
android:id="#+id/action_edit_account"
android:icon="#drawable/ic_action_edit"
android:orderInCategory="102"
app:showAsAction="never"
android:title="#string/action_edit_account"
android:visible="false"/>
<item
android:id="#+id/action_enable_offline_token"
android:orderInCategory="105"
app:showAsAction="never"
android:title="#string/action_enable_offline_token"
android:visible="false"/>
<item
android:id="#+id/action_disable_offline_token"
android:orderInCategory="105"
app:showAsAction="never"
android:title="#string/action_disable_offline_token"
android:visible="false"/>
<item
android:id="#+id/action_save"
android:icon="#drawable/ic_action_save"
android:orderInCategory="106"
app:showAsAction="ifRoom"
android:title="#string/action_save"
android:visible="false"/>
</menu>
Fragment:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
#Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
super.onCreateOptionsMenu(menu, inflater);
menu.findItem(R.id.action_refresh).setVisible(false);
menu.findItem(R.id.action_save).setVisible(true);
}
To change icons you can just get the menu and do a findItem and setIcon.
I have a menu layout with only one item in it.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/toolbar_right_button"
android:icon="#drawable/ic_toolbar_locked"
android:orderInCategory="1"
android:title="Logout"
app:showAsAction="always|withText"/>
</menu>
As you can see I've included the withText attribute but I still only get the icon.
How can I get both the icon and text to show?
I agree with your answer, but I had to do some digging to get it to work in my code, ultimately, I had to create an onClickListener for the button.
In my code, I wrote in the onCreateOptionsMenu(Menu menu) method:
menu.getItem(indexInMenu).getActionView().findViewById(R.id.button_logout).setOnClickListener(...);
This makes the menuItem responsive when it's replaced with a button in app:actionLayout
I'm not sure why withText wouldn't work for me so I just created an actionLayout to use instead.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/toolbar_right_button"
android:icon="#drawable/ic_toolbar_locked"
android:orderInCategory="1"
android:title="Logout"
app:actionLayout="#layout/menu_item_logout"
app:showAsAction="ifRoom|withText"/>
</menu>
and the actionLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="#+id/logout_button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="#drawable/ic_toolbar_locked"
android:gravity="center_vertical"
android:text="Logout"
android:textColor="#color/PrimaryColour"/>
</RelativeLayout>
I have try your menu xml, and it worked on android 4.1.1, 5.0.0
but it not worked on 4.3
to fix this, please refer to How to get text on an ActionBar Icon?
it use custom layout for the item
You could try:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity" >
<!-- "Mark Favorite", should appear as action button if possible -->
<!-- Settings, should always be in the overflow -->
<item
android:title="Settings"
android:id="#+id/mainMenu"
android:icon="#drawable/ic_3d_rotation_black_24dp"
app:showAsAction="always">
<menu>
<item
android:id="#+id/menu_logout1"
android:icon="#drawable/ic_3d_rotation_black_24dp"
android:title="logout1"/>
<item
android:id="#+id/menu_logout3"
android:icon="#drawable/ic_3d_rotation_black_24dp"
android:title="logout3"/>
</menu>
</item>
<item
android:id="#+id/menu_logout2"
android:icon="#drawable/ic_3d_rotation_black_24dp"
android:title="logout2"
app:showAsAction="always"/>
</menu>
Note, that this example will also paint some icons, so if you donĀ“t want the icons, just remove the icon attribute.
Remove icon from <item
android:icon="#drawable/ic_baseline_add_24"
Remove this line then it will show hope it worked for u
When the text in your toolbar menu items is not showing, this is probably related to your style settings. For example, when you have organized your style in a way that app title in toolbar is shown in white color, your menu items may become white on white.
To solve this, you need to set two attributes to your toolbar:
This is the general Style for the toolbar. Textcolor is white. Maybe you are using something like this when you are facing the "no text"-issue
<style name="ToolBarStyle" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
</style>
To make sure that text in menu is showing, not only set the app:theme of your toolbar but also the app:popuptheme. In this example popuptheme is set to a light theme because this leads to black text.
<androidx.appcompat.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#color/supplyon_blue"
app:theme="#style/ToolBarStyle"
app:popupTheme="#style/ThemeOverlay.MaterialComponents.Light"
android:id="#+id/toolbar" />
Play around with this setting and it will probably solve your problem.
I just started using toolbar instead of actionbar in my android app. But it shows a ridiculous settings button at the bottom of the screen and i couldn't find a way to erase it. Please help me with this.
Here is a screenshot for you to understand the problem:
http://i.stack.imgur.com/x1Gwe.png
Here is my code:
SetContentView(Resource.Layout.Main_Activity_Container);
var toolbar = FindViewById<Toolbar>(Resource.Id.Toolbar);
var toolbarBottom = FindViewById<Toolbar>(Resource.Id.BottomToolbar);
SetSupportActionBar(toolbar);
SupportActionBar.Title = "Hello from Toolbar";
SetSupportProgressBarIndeterminate(false);
toolbarBottom.Title = "";
toolbarBottom.InflateMenu (Resource.Menu.tabs);
toolbarBottom.MenuItemClick += delegate(object sender, Toolbar.MenuItemClickEventArgs e)
{
Toast.MakeText(this,
"Bottom toolbar pressed: " + e.Item.TitleFormatted, duration: ToastLength.Short).Show();
indeterminateVisible = !indeterminateVisible;
SetSupportProgressBarIndeterminateVisibility(indeterminateVisible);
};
axml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/Toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize"
android:layout_alignParentTop="true"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:background="?attr/colorPrimary" />
<android.support.v7.widget.Toolbar
android:id="#+id/BottomToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize"
style="#style/HeaderBar"
android:background="?attr/colorPrimary"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:layout_alignParentBottom="true" />
<FrameLayout
android:id="#+id/Container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/Toolbar"
android:layout_above="#id/BottomToolbar" />
</RelativeLayout>
styles.xml
<style name="MyTheme" parent ="#style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#1976D2</item>
<item name="windowActionModeOverlay">true</item>
<item name="colorAccent">#FF4081</item>
<item name="android:actionMenuTextColor">#24598a</item>
<item name="android:actionButtonStyle">#style/ActionButtonStyle</item>
</style>
<style name="ActionButtonStyle" parent="#style/Widget.AppCompat.ActionButton">
<item name="android:minWidth">70dip</item>
<item name="android:paddingStart">0dip</item>
<item name="android:paddingEnd">0dip</item>
</style>
tabs.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto">
<item android:id="#+id/menu_share"
android:icon="#drawable/icon"
local:showAsAction="always"
android:title="Edit" />
<item android:id="#+id/menu_share"
android:icon="#drawable/icon"
local:showAsAction="always"
android:title="Undo" />
<item android:id="#+id/menu_share"
android:icon="#drawable/icon"
local:showAsAction="always"
android:title="Redo" />
<item android:id="#+id/menu_share"
android:icon="#drawable/icon"
local:showAsAction="always"
android:title="Save" />
I also want to change the positions of these menu items. I know that i can use custom components inside of toolbars but i don't get why these menu items always appear in the right hand side.
Thank you.
I had the same issue, I resolved it by following below steps :
First of all to remove the disgusting settings button at bottom do the following :
In your activity, comment getMenuInflater().inflate(...) :
....
#Override
public boolean onCreateOptionsMenu(Menu menu) {
//getMenuInflater().inflate(R.menu.display_map, menu);
return true;
}
....
This will surely remove settings button from bottom, it did mine.
Now you can create your own menu items as normal views, add as many buttons as you want in your toolbar, whereever you want, see an example :
Toolbar is just a ViewGroup, So, in your toolbar.xml file or whereever you have defined android.support.v7.widget.Toolbar, change as per your requirements of buttons and their positions.
Below shows how to add an button at the center of toolbar, you can change it to your required position :
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/toolbar"
android:minHeight="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/color_toolbar"
android:layout_width="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="button"
android:onClick="buttonHandler"/>
</android.support.v7.widget.Toolbar>