I have the menu item that consists of 5 items which are Home, Property, Help, Users & Account. My question is, how should I do to make the Help menu looks like the picture below. Can someone help me?
Here is my xml code for menu
<?xml version="1.0" encoding="utf-8"?>
<item
android:id="#+id/nav_home"
android:icon="#drawable/bottom_menu_home_s"
android:title="Home" />
<item
android:id="#+id/nav_property"
android:icon="#drawable/bottom_menu_property_s"
android:title="Property" />
<item
android:id="#+id/nav_panic"
android:icon="#drawable/bottom_menu_panic"
android:title="Help" />
<item
android:id="#+id/nav_user"
android:icon="#drawable/bottom_menu_users_s"
android:title="Users" />
<item
android:id="#+id/nav_account"
android:icon="#drawable/bottom_menu_accounts_s"
android:title="Account" />
Try this, as you can not do directly
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
app:itemIconTint="#color/colorPrimary"
app:itemTextColor="#android:color/black"
app:menu="#menu/bottom_navigation"
android:clipChildren="false"
android:layout_height="56dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/help_button"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
app:elevation="6dp"
android:scaleType="center"/>
</com.google.android.material.bottomnavigation.BottomNavigationView>
You have to download/create customized icon first. Menu doesn't allow customization like a drawable.
Related
okay, Google Keeps-Notes and Lists App have a navigation drawer like this,
Google Keeps-Notes and Lists App Navigation Drawer(Original)
I want to do same exact as I mention in this image. I want this
'EDIT'
I want that EDIT (the TextView) at right side of navigation drawer.
I achieved this far,My Navigation Drawer
<group>
<item android:title="LABALS"
android:actionLayout="#layout/main_nav_drawer_edit">
<menu>
<item
android:id="#+id/navigation_drawer_lable"
android:title="Label 1" />
<item
android:id="#+id/navigation_drawer_create_new_label"
android:title="Create new label" />
</menu>
</item>
what should I do to achieve this, Is it possible?
Create a custom View and apply to the app:actionLayout attribute of your <item>.
<item
android:id="#+id/grp_labeled"
android:title="LABALS"
app:actionLayout="#layout/main_nav_drawer_edit">
<menu>
<item
android:id="#+id/navigation_drawer_lable"
android:title="Label 1" />
<item
android:id="#+id/navigation_drawer_create_new_label"
android:title="Create new label" />
</menu>
</item>
layout:
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EDIT"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
like this?
I'm using Bottom Navigation View in my application. Everything is working fine but I need to add selected purple line when one of the items is selected. How can I achieve this?
It's Easy,
Create a color folder in resource and paste the below xml
nav_item_color_state.xml (I am using blue color, modify as per your own)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#FF0096D6" android:state_checked="true" />
<item android:color="#FF666666" />
</selector>
and then "itemIconTint" and "itemTextColor"
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="#fff"
app:itemIconTint="#color/nav_item_color_state"
app:itemTextColor="#color/nav_item_color_state"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/navigation" />
I am trying to put active/inactive drawables for bottomnavigationview menu items. Going through several post in SO and browsing in Google I could find only setting colour for active/inactive state using app:itembackgroundColor what I want to achieve is set drawable when selected.
I tried this for menuitems
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/navigation_home"
android:icon="#drawable/home_navigation_view_home_selector"
android:checked="false"
android:title="#string/title_home" />
<item
android:id="#+id/navigation_dashboard"
android:icon="#drawable/home_navigation_view_oppurtunity_selector"
android:checked="false"
android:title="#string/title_oppurtunity" />
<item
android:id="#+id/navigation_notifications"
android:icon="#drawable/home_navigation_view_leads_selector"
android:checked="false"
android:title="#string/title_leads" />
<item
android:id="#+id/navigation_settings"
android:icon="#drawable/home_navigation_view_settings_selector"
android:checked="false"
android:title="#string/title_settings" />
</menu>
where
home_navigation_view_home_selector/
home_navigation_view_oppurtunity_selector/
home_navigation_view_leads_selector/
home_navigation_view_settings_selector
are selector for each item.
home_navigation_view_home_selector.xml
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/ic_home_selected"
android:state_checked="true" />
<item android:drawable="#drawable/ic_home_black_24dp" />
</selector>
the bottomnavigationview code is as follows
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?android:attr/windowBackground"
android:foreground="?attr/selectableItemBackground"
app:menu="#menu/navigation" />
but doesn't seem to work.
Any help will be appreciated.
Try:
navigation.setItemIconTintList(null);
in your code.
Bottom Navigation View uses color tinting by default, so you have to disable it.
I use navigation drawer activity in my code. For certain menu, icons are visible. But for the rest it appears as a shaded square/circle. I tried clean/rebuild/invalidate cache and restart options, still no solution. Any help please...
activity_main_drawer.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="#+id/fullstackdeveloper"
android:icon="#mipmap/ic_launcher_stack"
android:title="#string/home_label" />
<item
android:id="#+id/resourceperson"
android:icon="#mipmap/ic_launcher_person"
android:title="#string/about_us_label" />
<item
android:id="#+id/collegeworkshops"
android:icon="#mipmap/ic_launcher_workshop"
android:title="#string/portfolio_label" />
<item
android:id="#+id/tutorials"
android:icon="#mipmap/ic_launcher_tutorial"
android:title="#string/contacts_label" />
<item
android:id="#+id/tutorialvideos"
android:icon="#mipmap/ic_launcher_video"
android:title="#string/tutvideos_label" />
<item
android:id="#+id/scripts"
android:icon="#mipmap/ic_launcher_script"
android:title="#string/scripts_label" />
<item
android:id="#+id/androidapps"
android:icon="#mipmap/ic_launcher_android"
android:title="#string/androidapps_label" />
<item
android:id="#+id/analytics"
android:icon="#mipmap/ic_launcher_analytics"
android:title="#string/analytics_label" />
<item
android:id="#+id/python"
android:icon="#mipmap/pythonlogo"
android:title="#string/python_label" />
<item
android:id="#+id/rprogramming"
android:icon="#mipmap/rprogramming"
android:title="#string/rprogramming_label" />
<item
android:id="#+id/machinelearning"
android:icon="#mipmap/ic_launcher_machine"
android:title="#string/machinelearning_label" />
<item
android:id="#+id/booking"
android:icon="#mipmap/contacts"
android:title="#string/booking_label" />
</group>
Make sure you are following material design stander while creating icon for menu.
If you follow then it will show icons otherwise not.
You can confirm this by setting following icon
android:icon="#android:drawable/ic_menu_search"
You will see this icon in your drawer.
Above suggestion is 1 way to show icon in drawer other way is what #jeetparmar has suggest in above answer you can follow that also.
Try this way :
<?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">
<group android:checkableBehavior="single">
<item
android:id="#+id/Home"
app:actionLayout="#layout/home_item"
tools:ignore="MenuTitle" />
</group>
==========home_item============
<RelativeLayout
android:layout_width="match_parent"
android:layout_centerInParent="true"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/home"
android:layout_width="wrap_content"
android:src="#mipmap/home"
android:layout_centerVertical="true"
android:layout_height="wrap_content">
</ImageView>
<TextView
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:text="#string/HOME"
android:textColor="#color/colorblack"
android:layout_toRightOf="#+id/home"
android:layout_marginLeft="#dimen/_8sdp"
android:layout_height="wrap_content">
</TextView>
<ImageView
android:id="#+id/right"
android:alpha="0.3"
android:layout_width="#dimen/_20sdp"
android:src="#mipmap/right_arrow"
android:layout_margin="#dimen/_8sdp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="#dimen/_4sdp"
android:layout_height="#dimen/_20sdp">
</ImageView>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="#+id/right"
android:layout_marginLeft="#dimen/_22sdp"
android:background="#c0c0c0"/>
</RelativeLayout>
I set an icon for BottomNavigationView but it not show .
My code:
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="?android:attr/windowBackground"
app:menu="#menu/navigation" />
Menu :
<item
android:id="#+id/navigation_home"
android:icon="#drawable/ic_tab_bhxh"
android:title="#string/main_tab_social_bhxh"
app:showAsAction="ifRoom" />
<item
android:id="#+id/navigation_dashboard"
android:icon="#drawable/ic_tab_bhxh"
android:title="#string/main_tab_social_bhyt"
app:showAsAction="ifRoom" />
<item
android:id="#+id/navigation_notifications"
android:icon="#drawable/ic_tab_bhxh"
android:title="#string/main_tab_social_news"
app:showAsAction="ifRoom" />
and my program :
If you have any suggest , please tell my know .
After tried some image with different background , I resolved my issue with icon background color is white .