Swipe the menu items of bottom navigation bar - android

I am trying to add 4 items in menu of Bottom Navigation View but I cant figure out how to make it swipeable. The screenshot looks like this. I have figured out the increase in size but once I get to know the swiping so that a complete name can be visible or either wrap text can be applied.
My menu file is;
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/menu_1"
android:title="Triggered Insan" />
<item
android:id="#+id/menu_2"
android:title="Carry Minati" />
<item
android:id="#+id/menu_3"
android:title="Hadd Bc" />
<item
android:id="#+id/menu_4"
android:title="Lakshay Chaudhary" />
</menu>

Related

Android bottomnavigation view item icon size [duplicate]

This question already has answers here:
Why Floating action button Behind the BottomBar
(2 answers)
Closed 3 years ago.
I need to do a bottom navigation view in Android like this:
I tried, and now I have something like this:
How can I increase size of the + icon? It will be static and bigger then another icons all the time. Other icons will change color when activated, but the size will remain the same.
Activity xml:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBackground="#color/white"
app:layout_anchor="#id/bottom_navigation"
app:layout_constraintBottom_toBottomOf="parent"
app:labelVisibilityMode="labeled"
app:menu="#menu/bottom_navigation_main"
tools:layout_editor_absoluteX="4dp" />
Bottom navigation view xml:
<item
android:id="#+id/action_home"
android:enabled="true"
android:icon="#drawable/ic_home"
android:title="#string/home"
app:showAsAction="ifRoom"/>
<item
android:id="#+id/action_notification"
android:enabled="true"
android:icon="#drawable/ic_notification"
android:title="#string/notification"
app:showAsAction="ifRoom"/>
<item
android:id="#+id/action_add"
android:enabled="true"
android:title=" "
android:icon="#drawable/ic_add_circle"
app:showAsAction="ifRoom"
app:itemIconSize="50px"/>
<item
android:id="#+id/action_schedule"
android:enabled="true"
android:title="#string/schedule"
android:icon="#drawable/ic_schedule"
app:showAsAction="ifRoom" />
<item
android:id="#+id/action_profile"
android:enabled="true"
android:title="#string/profile"
android:icon="#drawable/ic_profile"
app:showAsAction="ifRoom" />
What you are trying can be achieved by using a 'Floating Action Button' on top of the Bottom Bar.
The third item in your Bottom Bar can then just be a placeholder. No action, name and icon on it.
A layout for example with a Floating Action Button on top is presented in this post, see the post for more information regarding possibly the same issue you are facing.
You could also take a look at this. The newer Bottom Bar of Google that includes functionality with a Floating Action Button.

Hide the top level menu when pop up sub menu is displayed in Android app

Android app has one top level menu named "Organisation" which gets displayed on the click of ellipsis (3 dots).
On touching this menu, pop up submenu gets displayed with top item as Organisation.
I want to hide this top level menu
and
only show 2 items in the sub pop up menu.
"Register Org" and "Change Org" are apps 2 sub popup menu items.
How do I do that? I tried below code which doesn't work.
MenuItem topLevelMenuOrganisation = menuList.findItem(R.id.idMenuOrganisation);
topLevelMenuOrganisation.setVisible(false);
Menu.xml
<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.example.jayantbhave.menuapps.MainActivity">
<item
android:id="#+id/idMenuOrg"
android:title="Organisation">
<menu>
<item
android:id="#+id/idMenuRegisterOrg"
android:title="Register Org" />
<item
android:id="#+id/idMenuChangeOrg"
android:title="Change Org" />
</menu>
</item>
</menu>
You can remove the "Organisation" item from the menu. Write your menu as following:
<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.example.jayantbhave.menuapps.MainActivity">
<item
android:id="#+id/idMenuRegisterOrg"
android:title="Register Org" />
<item
android:id="#+id/idMenuChangeOrg"
android:title="Change Org" />
</menu>
Hope it helps!

How to add sub menu into Bottom Navigation View

i want to add submenu into my bottom navigation view
and how do add into bottom navigation view?
i am try direct add into the menu item and it cannot run
bottom_navigation_menu.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">
<item
android:id="#+id/menu"
android:icon="#drawable/ic_menu"
android:title="#string/menu"
app:showAsAction="ifRoom"
android:enabled="true"/>
<item
android:id="#+id/promotion"
android:icon="#drawable/ic_promotion"
android:title="#string/promotion"
app:showAsAction="ifRoom"
android:enabled="true"/>
<item
android:id="#+id/order"
android:icon="#drawable/ic_order"
android:title="#string/order"
app:showAsAction="ifRoom"
android:enabled="true"/>
<item
android:id="#+id/location"
android:icon="#drawable/ic_location"
android:title="#string/location"
app:showAsAction="ifRoom"
android:enabled="true"/>
<item
android:id="#+id/more"
android:icon="#drawable/ic_more"
android:title="#string/more"
app:showAsAction="ifRoom"
android:enabled="true">
<menu>
<item
android:icon="#drawable/ic_more"
android:title="Sub item 1" />
<item
android:icon="#drawable/ic_more"
android:title="Sub item 2" />
</menu>
</item>
</menu>
For Add menu, you can use design:menu="#menu/bottom_navigation_menu" to your Bottom Navigation View.
Currently, You can't use subMenu in BottomNavigationView and only use maximum 5 menu items.
Check BottomNavigationView android developer doc.
If you want to have submenu for a menu item, your best shot is to have it in Navigation drawer as you cannot create a submenu inside BottomNavigationView.
Also, as per material design guidelines, there should be only 3 to 5 top level destinations(or menu items) in our BottomNavigationView. If you have less than 3 items, it is recommended to use tabs. And if you have more than 5 items, it is recommended to have the rest items inside Navigation drawer. Please refer the link below:
https://material.io/guidelines/components/bottom-navigation.html

Android navigation app change the icon of listed menus

I have use this code for menu icon but does not displayed in app why?
Please help me to to display icon left side of navigation menu list
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="#+id/income"
android:icon="#drawable/ic_income"
android:title="Income" />
<item
android:id="#+id/expense"
android:icon="#drawable/ic_expense"
android:title="Expense" />
<item
android:id="#+id/nav_settings"
android:icon="#drawable/ic_setting"
android:title="#string/nav_settings" />
</group>
</menu>
We have to set icon list as null then only it display the icon in navigation menu list
For that use following this code
navigationView.setItemIconTintList(null);

Menu Item in Action bar hide in small screen in android

I am using an actionbar with actionbar tab in an app. i have menu item and three tab with home icon in actionbar.
BUT When i run this app on emulator if menu item has property showAsAction with value "ifroom" then some of them are appear because of no more room
but the menu icon at the right upper corner is missing everytime i run this app.
Here is the image what is come in emulator :
and image below what i need :
here is my code for menu.xml:
<item android:id="#+id/menu_add" android:title="Add" android:icon="#drawable/icon" />
<item android:id="#+id/menu_DashBoard" android:title="DashBoard" />
<item android:id="#+id/menu_Master_Entry" android:title="Master Entry" />
<item android:id="#+id/menu_Product_Section" android:title="Product Section" />
<item android:id="#+id/menu_Retailers_Orders" android:title="Retailers Orders" />
<item android:id="#+id/action_search" android:icon="#drawable/search_icon"
android:title="Search" android:showAsAction="ifRoom" android:layout_gravity="left"/>
<item android:id="#+id/action_calender" android:title="Calender"
android:showAsAction="ifRoom" android:icon="#drawable/calender" android:layout_gravity="left" />
<item android:id="#+id/action_message" android:title="Message"
android:showAsAction="ifRoom" android:icon="#drawable/messageicon" android:layout_gravity="left"/>
Please help .. why it is come and what is the solution of this problem?
THANKS in advance. I only want that this menu dropdown at the last in actionbar should be shown in each screen size but it disappear in phone and shown on tab(10.1)
You can change android:showAsAction="ifRoom" to android:showAsAction="always"but this is not recommended.
If there is not enough room this items are added to more option at the end of the action bar where thr title of this item is shown in a drop-down (kind of) list.

Categories

Resources