1

Threre are 2 navigation views in my drawer layout.

First one is for classic navigation. Point of second one is to display linearlayout with interactive recyclerviews for current activity (not navigation).

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: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">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <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"/>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view2"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:fitsSystemWindows="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="bottom"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/nav_view_upper_rv"
                android:layout_width="match_parent"
                android:layout_height="250dp"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/nav_view_lower_rv"
                android:layout_width="match_parent"
                android:layout_height="250dp"/>

        </LinearLayout>

    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>

Second drawer I can open only by sliding it but I also want to open it by clicking on another (not-hamburger) icon on toolbar. Doing that way I want to combain all advantages of preset navigation and customizing in material design for both drawers.

Is it possible ? If I'm doing totally wrong advice me the right solution please

There are nearby questions: Two Navigation Drawer on same Activity

How to open Navigation Drawer with no actionbar, open with just a button

How to open Side bar on icon click in Android?

Dereva
  • 23
  • 1
  • 6
  • Why don't those last two links work for you? They show how to open/close the drawer programmatically, so then you just have to decide if you want to use some kind of button in your `Toolbar`, or a menu item, and examples are given for both options. – Mike M. Oct 28 '17 at 09:56
  • @Mike M. Thanks for the response. Honestly in these examples I don't understand how clicking button open exactly second drawer. There is no reference on nav_view2, only on drawerlayout generally – Dereva Oct 28 '17 at 10:19
  • Most of those examples show using the `DrawerLayout#openDrawer()` method with the drawer's `layout_gravity`. In your case, you'd use `GravityCompat.END`, so you don't really need a reference to the `NavigationView` - `drawerLayout.openDrawer(GravityCompat.END);`. If you'd rather, `openDrawer()` can also take a `View`, so you could also pass your `NavigationView` - e.g., `NavigationView navView = (NavigationView) findViewById(R.id.nav_view2);`, `drawerLayout.openDrawer(navView);`. Either way will work. – Mike M. Oct 28 '17 at 10:37
  • @MikeM.Thanks a lot for your help! – Dereva Oct 28 '17 at 13:06

0 Answers0