Issue in Navigation Drawer menu items - android

Actually we have some text fields and icons in navigation menu drawer.we want some text fields are become transparent color and remaining items are in full black color..only icons are become a transparent not text in my app.so any one fix this issue?
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_dashboard"
android:enabled="true"
android:icon="#drawable/ic_dashboard_black_24dp"
android:title="Dashboard" />
<item
android:id="#+id/nav_my_business"
android:icon="#drawable/ic_business_center_black_24dp"
android:title="My Business" />
<item
android:id="#+id/nav_trending_gifs"
android:icon="#drawable/trending_gifts"
android:title="Trending Gifts" />
<item
android:id="#+id/nav_orders"
android:icon="#drawable/ic_description_black_24dp"
android:title="Orders" />
<item
android:id="#+id/nav_cards"
android:icon="#drawable/ic_card_giftcard_black_24dp"
android:title="E-Gift Cards & Vouchers" />
<item
android:id="#+id/nav_manage_my_store"
android:enabled="false"
android:icon="#drawable/ic_store_black_24dp"
android:title="Manage my store" />
<item
android:id="#+id/nav_payments"
android:enabled="false"
android:icon="#drawable/ic_payment_black_24dp"
android:title="Payments" />
<item
android:id="#+id/nav_mnager"
android:icon="#drawable/ads_manager"
android:enabled="false"
android:title="Ads Manager" />
<item
android:id="#+id/nav_reviews_ratings"
android:enabled="false"
android:icon="#drawable/ic_rate_review_black_24dp"
android:title="Reviews & Ratings" />
<item
android:id="#+id/nav_wallet"
android:enabled="false"
android:icon="#drawable/ic_account_balance_wallet_black_24dp"
android:title="Wallet" />
<item
android:id="#+id/nav_help"
android:enabled="false"
android:icon="#drawable/ic_help_black_24dp"
android:title="Help/Support" />
<item
android:id="#+id/nav_about"
android:enabled="false"
android:icon="#drawable/ic_info_black_24dp"
android:title="About" />
</group>

You can use tint color for icons to visible in any color. Something like this
<android.support.design.widget.NavigationView
android:id="#+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
**app:itemIconTint="#color/menu_icon"**
app:itemBackground="#color/menu_group_colour"
android:background="#android:color/black"
app:itemTextColor="#ffffff">
<include layout="#layout/navigation_item"/>
</android.support.design.widget.NavigationView>

Related

Set active/inactive drawables for bottomavigationview

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.

setting background and text color to topmost item in hamburger android

I want to set a black background with a white textview to the topmost item of the hamburger menu.It tried dynamically but setting Menu Item class does not have any propert setBackgroundDrawable etc.This is my menu and I want to set the background to navigation_item_1.pls help me
<?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:id="#+id/grp1" android:checkableBehavior="single" >
<item
android:id="#+id/navigation_item_1"
android:checked="true"
android:icon="#drawable/ic_home"
android:title="get i5 Pro" />
</group>
<group android:checkableBehavior="single">
<item
android:id="#+id/home"
android:icon="#drawable/ic_home"
android:title="Home"/>
<item
android:id="#+id/activate_pro"
android:icon="#drawable/ic_pro"
android:title="Active PRO"/>
<item
android:id="#+id/my_music"
android:icon="#drawable/ic_music_list"
android:title="My Music"/>
<item
android:id="#+id/nav_browse"
android:icon="#drawable/ic_brows_black"
android:title="Browse and Discover" />
<item
android:id="#+id/radio_stations"
android:icon="#drawable/ic_radio_station"
android:title="Radio Stations"/>
<item
android:id="#+id/new_releases"
android:icon="#drawable/ic_new_release"
android:title="New Releases"/>
<item
android:id="#+id/my_profile"
android:icon="#drawable/ic_profile"
android:title="My Profile" />
<item
android:id="#+id/music_lang"
android:icon="#drawable/ic_checked"
android:title="Music Languages" />
<item
android:id="#+id/settings"
android:icon="#drawable/ic_settings"
android:title="Settings"/>
<item
android:id="#+id/nav_login"
android:icon="#drawable/ic_logout"
android:title="Log in " />
<item
android:id="#+id/nav_log_out"
android:icon="#drawable/ic_logout"
android:title="Log out " />
</group>
</menu>
In xml file having navigation view add following code inside navigation view as :
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="horizontal"
android:layout_marginTop="330dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/ic_home"/>
<TextView
android:id="#+id/mSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:textColor="#ffffff"
android:text="get i5 Pro" />
</LinearLayout>
</android.support.design.widget.NavigationView>
Where you have to give margin top of linear layout according to your header height.. e.g. If your header height is 320 dp then you need to increase is by 10 dp or more according to your requirement.

Ripple effect not showing on navigation drawer item clicked state

my NavigationView:
<android.support.design.widget.NavigationView
android:id="#+id/navigationView"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
app:headerLayout="#layout/header"
app:menu="#menu/drawer"
app:itemTextColor="#android:color/black"
app:itemBackground="?attr/selectableItemBackground" />
drawer.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group
android:id="#+id/mainActions"
android:checkableBehavior="single">
<item
android:id="#+id/firm"
android:checked="false"
android:icon="#drawable/firm"
android:title="#string/firm" />
<item
android:id="#+id/surveys"
android:checked="false"
android:icon="#drawable/surveys"
android:title="#string/surveys" />
<item
android:id="#+id/results"
android:checked="false"
android:icon="#drawable/results"
android:title="#string/results" />
<item
android:id="#+id/notifications"
android:checked="false"
android:icon="#drawable/notifications"
android:title="#string/notifications" />
</group>
<group
android:id="#+id/subActions"
android:checkableBehavior="single">
<item
android:id="#+id/settings"
android:checked="false"
android:icon="#drawable/settings"
android:title="#string/settings" />
<item
android:id="#+id/logout"
android:checked="false"
android:icon="#drawable/logout"
android:title="#string/logout" />
</group>
I am running the app on Android 6 Galaxy Note 4 device. When I press each navigation drawer item only the color of the icon is changed to light blue. i would like to change also the text color of each item and have ripple effect shown.
Set a color selector for the
app:itemTextColor="#color/selector_nav_items"
Where the selector itself is
res/color/selector_nav_items:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#color/your_light_blue_color" android:state_pressed="true"/>
<item android:color="#android:color/black"/>
</selector>

how to make navigation drawer using navigation view with custom layout for the rows android

I am making navigation drawer with navigaiton view (content is taking from menu)
<android.support.design.widget.NavigationView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/drawer_view"/>
I want to change the default layout of the menu from drawer_view.xml.
Is android provide any means(actionLayout not working) for changing the default layout of menus
Create drawer.xml inside menu folder and add this.
<?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/home"
android:checked="false"
android:icon="#drawable/home"
android:title="Home" />
<item
android:id="#+id/info"
android:checked="false"
android:icon="#drawable/info"
android:title="Info" />
<item
android:id="#+id/other"
android:checked="false"
android:icon="#drawable/other"
android:title="Other" />
<item
android:id="#+id/other1"
android:checked="false"
android:icon="#drawable/other1"
android:title="Other 1" />
<item android:title="Sub Menus">
<menu>
<item
android:id="#+id/sub_one"
android:icon="#drawable/sub"
android:title="Sub item 1" />
<item
android:id="#+id/sub_two"
android:icon="#drawable/sub"
android:title="Sub item 2" />
<item
android:id="#+id/sub3"
android:icon="#drawable/sub"
android:title="Sub item 3" />
<item
android:id="#+id/sub4"
android:icon="#drawable/sub"
android:title="Sub item 4" />
</menu>
</item>
</group>
</menu>
And replace
app:menu="#menu/drawer_view"
inside NavigationView with this
app:menu="#menu/drawer"
So you can edit images and text for each menu option.

No horizontal line displayed between options menu item

I implemented an options menu in my application using menu.xml. And the menu is displayed in two rows. But there is no line separator horizontally between these rows of menuItems. But other applications shows menu items with line separator by default.
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/scan"
android:icon="#drawable/scan"
android:title="Scan" />
<item android:id="#+id/imei"
android:icon="#drawable/imei"
android:title="IMEI" />
<item android:id="#+id/serno"
android:icon="#drawable/serno"
android:title="SerialNo" />
<item android:id="#+id/update"
android:icon="#drawable/update"
android:title="Updates" />
<item android:id="#+id/about"
android:icon="#drawable/about"
android:title="About" />
<item android:id="#+id/exit"
android:icon="#drawable/exit"
android:title="Exit" />
</menu>
Am I missing something? Thanks in advance.

Categories

Resources