Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
removed incorrect xml
Source Link
hungryghost
  • 9.7k
  • 3
  • 25
  • 36

Problem #1

Your menu needs to have <menu> as the root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

Check your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first.

Update:

If your navigation drawer is drawing underneath your action bar (like you mentioned in the comments), it's because ofrelated to your layout, not your menu items. Try adding android:fitsSystemWindows="true"toPlease post how you are creating your action bar NavigationView(either in code or in xml, like this:).

<android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/drawer_header" app:menu="@menu/drawer"/> 

Problem #1

Your menu needs to have <menu> as the root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

Check your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first.

Update:

If your navigation drawer is drawing underneath your action bar (like you mentioned in the comments), it's because of your layout, not your menu items. Try adding android:fitsSystemWindows="true"to your NavigationView xml, like this:

<android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/drawer_header" app:menu="@menu/drawer"/> 

Problem #1

Your menu needs to have <menu> as the root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

Check your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first.

Update:

If your navigation drawer is drawing underneath your action bar (like you mentioned in the comments), it's related to your layout, not your menu items. Please post how you are creating your action bar (either in code or in xml).

added 417 characters in body
Source Link
hungryghost
  • 9.7k
  • 3
  • 25
  • 36

Problem #1

Problem #1

Your menu needs to have <menu> as the root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

Problem #2

I'm not sure what you're asking. If your header view is not displaying correctly, checkCheck your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first.

Update:

If you're still having problemsyour navigation drawer is drawing underneath your action bar (like you mentioned in the comments), postit's because of your layout XML so we can help, not your menu items. Try adding android:fitsSystemWindows="true"to your NavigationView xml, like this:

<android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/drawer_header" app:menu="@menu/drawer"/> 

Problem #1

Your menu needs to have <menu> as the root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

I'm not sure what you're asking. If your header view is not displaying correctly, check your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first. If you're still having problems, post your layout XML so we can help.

Problem #1

Your menu needs to have <menu> as the root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

Check your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first.

Update:

If your navigation drawer is drawing underneath your action bar (like you mentioned in the comments), it's because of your layout, not your menu items. Try adding android:fitsSystemWindows="true"to your NavigationView xml, like this:

<android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/drawer_header" app:menu="@menu/drawer"/> 
grammar
Source Link
hungryghost
  • 9.7k
  • 3
  • 25
  • 36

Problem #1

Your menu needs to have <menu> as it'sthe root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

I'm not sure what you're asking. If your header view is not displaying correctly, check your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first. If you're still having problems, post your layout XML so we can help.

Problem #1

Your menu needs to have <menu> as it's root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

I'm not sure what you're asking. If your header view is not displaying correctly, check your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first. If you're still having problems, post your layout XML so we can help.

Problem #1

Your menu needs to have <menu> as the root element, like this:

<menu> <item android:id="@+id/navigation_item_1" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </menu> 

If you really want to use submenus, then place another <menu> inside of a top-level <item>. See Menu Resource for more info on how to nest these elements.

Problem #2

I'm not sure what you're asking. If your header view is not displaying correctly, check your layout_width and layout_height. Also, make sure it displays correctly in your IDE layout editor first. If you're still having problems, post your layout XML so we can help.

Source Link
hungryghost
  • 9.7k
  • 3
  • 25
  • 36
Loading