navigationview

How can I change separator color in NavigationView?

淺唱寂寞╮ 提交于 2019-11-27 00:20:12
I'm trying to use NavigationView to implement NavigationDrawer. I have added the separator by setting group id in menu. However I can't see the separator. I guess it is because the separator color is same as the background. So I want to change the separator color. But I find no way to change it. Can anyone help me? In screenshot, it seems have a room for separator between History and Settings , but you can't see it. activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http:/

How I can remove the unnecessary top padding of the Navigation view?

一曲冷凌霜 提交于 2019-11-26 22:29:11
There's an unnecessary top padding between the header and the first item shown in this picture. How it can be removed? you can find the source code here: https://github.com/chrisbanes/cheesesquare ianhanniballake NavigationView seeks to match the material design specs for the navigation drawer which state an 8dp space between content areas. Generally there are no ways to override NavigationView to specifically break the specifications. You can override predefined dimensions at your dimens.xml as; <dimen name="design_navigation_padding_top_default" tools:override="true">0dp</dimen> <dimen name=

setNavigationItemSelectedListener Not Working

五迷三道 提交于 2019-11-26 22:04:42
问题 My NavigationView onClick event is not working. Here are the code snippets I tried one by one, but nothing worked: Implementing NavigationView.OnNavigationItemSelectedListener using OnClick() Method Setting NavigationItemSelectedListener method nav = (NavigationView)findViewById(R.id.nav); nav.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem item) { Toast.makeText(getApplicationContext(),"Hello

NavigationView menu items with counter on the right

只谈情不闲聊 提交于 2019-11-26 21:39:09
The new NavigationView in the new Design Support Library works really great. They use " menu-items " to display the options. But how can I display a counter to the right of the menu item? Like in this picture: Or like in the GMail app. Starting from version 23 of appcompat-v7 NavigationView supports action views, so it is quite easy to implement counter yourself. Create counter layout, i.e. menu_counter.xml : <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="match_parent"

NavigationView and custom Layout

寵の児 提交于 2019-11-26 17:07:45
I'm using the Designs Support Libraries NavigationView like this: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_height="match_parent" android:layout_width="match_parent" android:fitsSystemWindows="true"> <!-- put your main layout here --> <include layout="@layout/drawer_main_layout"/> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_height="match_parent" android:layout_width="wrap_content" android:layout

Is there any way to control views inside NavigationView header?

允我心安 提交于 2019-11-26 16:14:01
问题 As the title says, I want to know if there is any way to control views inside the NavigationView header? (Except for adding or removing header.) For example: In the header, I have a user avatar. By default, it displays a guest image, but after the user logs in, the real avatar will be showed. How can this be accomplished? 回答1: After updating your support library to version 23.1.1 or above, You could do this - View header = navigationView.getHeaderView(0); TextView text = (TextView) header

How to create a simple divider in the new NavigationView?

狂风中的少年 提交于 2019-11-26 12:46:16
Google introduced the NavigationView in the Design Support Library version 22.2.0 with which you can create a drawer very easily using a menu resource. How can I create a simple divider line between two items? Grouping the items didn't work. Creating a sub items section does create a divider line, but it requires a title, which I don't want. Any help would be appreciated. N J All you need to do is define a group with an unique ID , I have checked the implementation if group has different id's it will create a divider. Example menu, creating the separator: <menu xmlns:android="http://schemas

NavigationView OnNavigationItemSelectedListener not being called

ぃ、小莉子 提交于 2019-11-26 12:30:07
I am trying to use NavigationView from Android Support Design library in my app. For some reason, OnNavigationItemSelected listener is not being called. Here is my code Activity Layout <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.NavigationView android:id="@+id/navigation_view"

Android - Navigation View item menu background color

大憨熊 提交于 2019-11-26 11:09:35
问题 i try to change color of my item Navigation View menu : styles.xml <item name=\"android:activatedBackgroundIndicator\">@drawable/activated_background</item> activated_background.xml <selector xmlns:android=\"http://schemas.android.com/apk/res/android\"> <item android:state_pressed=\"true\" android:drawable=\"@color/White\" /> <item android:state_focused=\"true\" android:drawable=\"@color/White\" /> <item android:state_activated=\"true\" android:drawable=\"@color/White\" /> <item android

How can I change separator color in NavigationView?

对着背影说爱祢 提交于 2019-11-26 09:23:12
问题 I\'m trying to use NavigationView to implement NavigationDrawer. I have added the separator by setting group id in menu. However I can\'t see the separator. I guess it is because the separator color is same as the background. So I want to change the separator color. But I find no way to change it. Can anyone help me? In screenshot, it seems have a room for separator between History and Settings , but you can\'t see it. activity_main.xml <?xml version=\"1.0\" encoding=\"utf-8\"?> <android