android-navigationview

Add a MenuItem to Menu at specific position or group programmatically

断了今生、忘了曾经 提交于 2019-12-06 19:14:36
问题 I have a <android.support.design.widget.NavigationView app:menu="@menu/drawer" /> with the following menu items: <item android:id="@+id/main_item" android:icon="@drawable/ic_menu_main" android:title="@string/app_name"/> <group android:id="@+id/some_group" android:checkableBehavior="single"/> <item android:id="@+id/teams_item" android:icon="@drawable/ic_menu_teams" android:title="@string/teams"/> Now I want to add an item either to the some_group or just below it. I tried: MenuItem mi = menu

NavigationView theme selected item background style

时间秒杀一切 提交于 2019-12-06 04:28:16
I have created an alternative theme for my app which is Dark. I use a navigation bar which is defined 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" /> It has two groups defined within the menu which are selectable <item android:id="@+id/sort_item" android:title="One"> <menu> <group android:id="@+id/menu_group_sort" android:checkableBehavior="single">

Where to findViewById in a Drawer MainActivity?

久未见 提交于 2019-12-05 21:46:37
I'm using the Android Studio template for the Drawer Navigation. I wanted to add a click event to the drawer's header, but when I try to findViewById in the onCreate() method, I get a null exception. I'm guessing it's because it hasn't been inflated yet. Interesting to me is that findViewById on the drawer_layout and the nav_view returned an object. I tried to do this: drawer.findViewById; and this: navigationView.findViewById; But that still gives me an exception. So my question is two fold: Why is it that findViewById on drawer_layout and nav_view returned an object while findViewById on iv

Error inflating class com.google.android.material.navigation.NavigationView after migration to AndroidX

别来无恙 提交于 2019-12-05 18:08:35
After I updated my project to AndroidX with targetSdkVersion set to 28, my project crashes on installing it from the store for beta testing. The following is the error log I receive: 2019-07-08 08:28:33.026 32011-32011/? E/AndroidRuntime: FATAL EXCEPTION: main Process: hu.itq.oakprotection, PID: 32011 java.lang.RuntimeException: Unable to start activity ComponentInfo{hu.itq.oakprotection/hu.itq.oakprotection.MainActivity}: android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class com.google.android.material.navigation.NavigationView at android.app

Disable a color tint in NavigationView only for specified icons

别来无恙 提交于 2019-12-05 15:37:58
问题 I need to disable a tint color for some icons in NavigationView because their color define category type. How can I do it? Below picture shows my problem: 回答1: navview.setItemIconTintList(null); Good luck! 回答2: If you want change color of icon on seletion the below is the possible answer: Change Navigation View Item Color Dynamicly Android Otherwise you can set navview.setItemIconTintList(null); this will give the original colors of icons. and you can use colored and grey icons as per your

What is the navigation drawer icons size?

删除回忆录丶 提交于 2019-12-05 13:20:36
问题 I need to know the correct size (artboard and content) for Navigation Drawer icons. It doesn't say anything on the Navigation Drawer specs: http://www.google.com.br/design/spec/patterns/navigation-drawer.html#navigation-drawer-specs Thanks! 回答1: I would vote up Balar's answer, but it is off by one small detail. The correct answer is that all small icons should be 24 x 24 dp . Reference: https://material.io/guidelines/layout/metrics-keylines.html#metrics-keylines-touch-target-size 回答2: For:

Class Not Found Android Support Design Widget NavigationView

这一生的挚爱 提交于 2019-12-05 06:45:50
Good day, can you help me out. I got this error when compiling/running my code on an emulator. This is the sample tutorial I used to make. I used min Target API - 15 and compile the latest gradle 'com.android.support:design:23.0.0' http://www.android4devs.com/2015/06/navigation-view-material-design-support.html Code Error: AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eccp.projects.ecosavers.ecosavers/com.eccp.projects.ecosavers.ecosavers.activities.MainActivity}: android.view.InflateException: Binary XML file line #29: Binary XML file line #29: Error

Add a MenuItem to Menu at specific position or group programmatically

送分小仙女□ 提交于 2019-12-05 00:58:54
I have a <android.support.design.widget.NavigationView app:menu="@menu/drawer" /> with the following menu items: <item android:id="@+id/main_item" android:icon="@drawable/ic_menu_main" android:title="@string/app_name"/> <group android:id="@+id/some_group" android:checkableBehavior="single"/> <item android:id="@+id/teams_item" android:icon="@drawable/ic_menu_teams" android:title="@string/teams"/> Now I want to add an item either to the some_group or just below it. I tried: MenuItem mi = menu.add( R.id.soume_group, someId, NONE, "some name" ); or MenuItem mi = menu.add( R.id.soume_group, someId,

What's the purpose of tools:openDrawer=“start” when creating a DrawerLayout (with NavigationView) from the wizard?

大城市里の小女人 提交于 2019-12-04 23:15:46
Creating an activity with navigation drawer in Android Studio causes this to be shown in the XML code: <android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> If I remove the tools:openDrawer="start" , on the layout preview, the navigation drawer will be closed instead of open. I thought this

How can I get menu item in NavigationView?

半世苍凉 提交于 2019-12-04 08:48:26
问题 <android.support.design.widget.NavigationView android:id="@+id/drawer_nav" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:theme="@style/Theme.AppCompat.Light.NoActionBar" app:headerLayout="@layout/drawer_header" app:menu="@menu/menu_drawer" /> I am using android.support.design.library for material design. What I want is to hide some menu items when the user is not logged-in. Now I have trouble to get the menu item in