When i added additional item to menu, it go off the screen on phone with smaller screen like 400x800. I tried to add padding but i don't want to make icon smaller but only move whole menu a little bit to the left because i see there is space for that. Does anyone has similar problem and resolve it ?
code:
<?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/graphic"
android:icon="#drawable/ic_graphic_white_30dp"
android:title="Graphic"
app:showAsAction="always" />
<item
android:id="#+id/save"
android:icon="#drawable/ic_save_white_24dp"
android:title="#string/save"
app:showAsAction="always" />
<item
android:id="#+id/share"
android:icon="#drawable/ic_share_white_24dp"
android:title="#string/share"
app:showAsAction="always" />
<item
android:id="#+id/count"
android:icon="#drawable/ic_pie_chart_white_24dp"
android:title="#string/count"
app:showAsAction="always" />
<item
android:id="#+id/camera"
android:icon="#drawable/ic_camera_alt_white_24dp"
android:title="#string/photo"
app:showAsAction="always" />
<item
android:id="#+id/lock"
android:icon="#drawable/ic_action_secure"
android:title="#string/lock"
app:showAsAction="always" />
</menu>
You can use configrations of your actionBar as below:
ActionBar mActionBar = getSupportActionBar();
mActionBar.setNavigationMode(NAVIGATION_MODE_LIST);
mActionBar.setListNavigationCallbacks(mAdapter, mNavigationCallback);
You can follow this example : Sample Here
Related
I have created a custom Toolbar, but all of the elements in it have no methods of moving. I just want to replace Fenix icon in left side on the toolbar (maybe with help of margins).
Here's my XML menu code:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/risensteam_button"
android:title="#string/main"
android:icon="#drawable/ic_action_unnamed"
app:showAsAction="always" />
<item
android:id="#+id/news_button"
android:icon="#drawable/news_icon"
android:title="#string/main"
app:showAsAction="always" />
<item
android:id="#+id/ongoing_button"
android:icon="#drawable/ongoing_icon"
android:title="#string/ongoing"
app:showAsAction="always" />
<item
android:id="#+id/base_button"
android:icon="#drawable/base_icon"
android:title="#string/base"
app:showAsAction="always" />
<item
android:id="#+id/manga_button"
android:icon="#drawable/manga_icon"
android:title="#string/manga"
app:showAsAction="always" />
<item
android:id="#+id/novels_button"
android:icon="#drawable/novels_icon"
android:title="#string/novels"
app:showAsAction="always" />
you can also add custom toolbar not use action menu add as image in toolbar as per your requirement
<?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/menu_reply"
android:icon="#drawable/ic_reply_white_24dp"
android:title="Reply"
app:showAsAction="always" />
<item
android:id="#+id/menu_favourite"
android:icon="#drawable/ic_grade_white_24dp"
android:title="Favourite"
app:showAsAction="always" />
<item
android:id="#+id/menu_info"
android:icon="#drawable/ic_info_outline_white_24dp"
android:title="Info"
android:visible="false"
app:showAsAction="always" />
<item
android:id="#+id/menu_delete"
android:icon="#drawable/ic_delete_white_24dp"
android:title="Delete"
app:showAsAction="always" />
<item
android:id="#+id/menu_copy"
android:icon="#drawable/ic_content_copy_white_24dp"
android:title="Copy"
app:showAsAction="always" />
<item
android:id="#+id/menu_right_arrow"
android:icon="#drawable/ic_arrow_right_bold_white_24dp"
android:title="Forward"
app:showAsAction="always" />
<item
android:id="#+id/menu_message"
android:icon="#drawable/ic_arrow_right_bold_white_24dp"
android:title="Message xyz"
app:showAsAction="always" />
<item
android:id="#+id/menu_call"
android:icon="#drawable/ic_arrow_right_bold_white_24dp"
android:title="Call xyz"
app:showAsAction="always" />
</menu>
I'm using Action mode menu while long click on list item. It is always showing max 2 items, even it has space to show more items in Action mode menu. I'm assigning android:showAsAction = "always" for all the items. I'm expecting to design screen like WhatsApp long press showing 5 items with icons.
Use android:showAsAction="always" property along with app:showAsAction="always".
<item
android:id="#+id/menu_reply"
android:icon="#drawable/ic_reply_white_24dp"
android:title="Reply"
app:showAsAction="always"
android:showAsAction="always" />
Use import android.support.v7.view.ActionMode and
yourActionMode = startSupportActionMode(mActionModeCallback)
it solves this problem.
Hi, how can I make my menu items have icons as well when showAsAction is never ?
Use android:actionLayout in menu item tag to specify custom lyout (icon with text).
Menu item will look like:
<item
android:id="#+id/edit_menu"
android:actionLayout="#layout/custom_edit_row"
android:orderInCategory="100"
android:title="#string/edit"
app:showAsAction="always"></item>
Edit
custom_edit_row.xml
will be:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayout1"
style="#android:style/Widget.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true">
<ImageView
android:id="#+id/imageViewEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/edit_ic" />
<TextView
android:id="#+id/tvEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Edit" />
<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=".YourActivityName">
<item
android:id="#+id/action_settings"
android:icon="#android:drawable/btn_dialog"
android:title="#string/action_settings"
app:showAsAction="always">
<menu>
<item
android:id="#+id/profile"
android:icon="#drawable/common_google_signin_btn_icon_light_disabled"
android:title="PROFILE"
app:showAsAction="always" />
</menu>
</item>
Use this menu file, it worked fine for me.
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/action_m"
android:showAsAction="never"
android:title="menu">
<menu>
<item
android:id="#+id/action_one"
android:icon="#android:drawable/ic_popup_sync"
android:showAsAction="always"
android:title="Sync"/>
<item
android:id="#+id/action_two"
android:icon="#android:drawable/ic_dialog_info"
android:title="About"/>
</menu>
</item>
</menu>
In createOptionsMenu, set the icon and text to MenuItem.
Elaborate the problem a little more.
Just change root item of Harry Mad answer
<item
android:title="Ещё"
app:showAsAction="always"
android:icon="#drawable/ic_more_vert">
...
i create application with default android studio menu, but when i change default icon with my drawable icon this circle icon is not visible.
my problem is how can i show icon in my android menu.
I used this XML:
<?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"
>
<group android:checkableBehavior="single">
<item android:id="#+id/nav_radio" android:icon="#drawable/radio_icon"
android:title="Radio" />
<item android:id="#+id/nav_tv" android:icon="#drawable/tv_icon"
android:title="TV" />
</group>
<item android:title="Autre">
<menu>
<item android:id="#+id/nav_share" android:icon="#drawable/share_icon"
android:title="Share" />
<item android:id="#+id/nav_send" android:icon="#drawable/mail_icon"
android:title="Send" />
<item android:id="#+id/nav_like" android:icon="#drawable/heart_icon"
android:title="Rate Me" />
<item android:id="#+id/nav_recording" android:icon="#drawable/cloud_icon"
android:title="Recording" />
<item android:id="#+id/nav_close" android:icon="#drawable/power_icon"
android:title="Close" />
</menu>
</item>
</menu>
and i don't show icone
please help me
In you activity Where you have used NavigationView use this one line of code. doing this may solve your problem.
setItemIconTintList(null);
in your Activity
mNavigation = (NavigationView) findViewById(R.id.navigation);
mNavigation.setItemIconTintList(null);
so i made my own toolbar with a menu and i am infalting it:
toolbarBottom.inflateMenu (R.menu.user_interaction);
and this is the menu
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res/android">
<item app:title="Edit"
app:id="#+id/post"
app:icon="#drawable/ic_action_pinboard_white"
app:showAsAction="always"
/>
<item app:id="#+id/menu_share"
app:icon="#drawable/ic_action_recent_white"
app:showAsAction="always"
app:title="Undo" />
<item app:id="#+id/test"
app:icon="#drawable/ic_action_groups_white"
app:showAsAction="always"
app:title="Redo" />
</menu>
what i get now is the 3 android option dots on the right side of my bar. If i press it my 3 menu´s appear. What i want is the 3 menu items to appear on the bar itself witht he 3 icon drawables.
Where is my mistake? Did i forgot something? :O
ok i solved it like this:
<?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:title="Edit"
android:id="#+id/post"
android:icon="#drawable/ic_action_pinboard_white"
app:showAsAction="always"
/>
<item android:id="#+id/menu_share"
android:icon="#drawable/ic_action_recent_white"
app:showAsAction="always"
android:title="Undo" />
<item android:id="#+id/test"
android:icon="#drawable/ic_action_groups_white"
app:showAsAction="always"
android:title="Redo" />
</menu>
It should be:
<?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:title="Edit"
android:id="#+id/post"
android:icon="#drawable/ic_action_pinboard_white"
app:showAsAction="always"
/>
<item android:id="#+id/menu_share"
android:icon="#drawable/ic_action_recent_white"
app:showAsAction="always"
android:title="Undo" />
<item android:id="#+id/test"
android:icon="#drawable/ic_action_groups_white"
app:showAsAction="always"
android:title="Redo" />
</menu>