In my project there is a resource for the menu. You can view this resource in design-mode, that's great. But in this mode, the menu is presented as if it was placed in ActonBar / Toolbar. Suppose I want to use this menu in NavigationLayout, where it will, of course, look a little different. Is there a way to look at the menu in design-mode so that it appears as if placed in the NavigationLayout?
1 answer
We find DrawerLayout fasten to it tools:openDrawer="start" , which will show it in expanded form in the preview (left can be), well, this is already pure RTL. Example:
<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"> After you need in xml through the app scheme, add a menu, app:menu="@menu/activity_main_drawer" looks like this:
<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"/> After that, the preview screen will look something like this: Screen c Preview 
- Well, it does not suck what I was looking for. We look at the activit in which there is a NavigationView in which there is a menu. And so immediately in the resource of the menu itself? - P. Ilyin
|