Skip to content

Jantzilla/SimpleDrawerLayout

Repository files navigation

SimpleDrawerLayout

This library provides a way to create simple or complex drawer implementations in a single layout!

How to

Gradle

dependencies {
    implementation 'com.creativesource:simpledrawerlayout:0.1.0'
}

In your XML layout

<com.creativesource.simpledrawerlayout.SimpleDrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/simple_drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:headerLayout="@layout/header"
    app:menuRes="@menu/menu"
    app:drawerGravity="start">

Custom Attributes

Attribute Description
headerLayout Location of header layout resource
drawerItem Whether or not to place layout item inside the drawer (default - false)
drawerGravity Determines which direction drawer opens (default - Gravity.START)
menuRes Location of menu resource

In your Java code

    simpleDrawerLayout = (simpleDrawerLayout) findViewById(R.id.simple_drawer_layout);
    
    simpleDrawerLayout.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
                
                menuItem.setChecked(true);
                simpleDrawerLayout.closeDrawers();
                
                return true;
            }
        });

Custom Methods

Method Description
setNavigationItemSelectedListener
(OnNavigationItemSelectedListener navigationListener)
Sets drawer navigation item listener
openDrawer(int gravity) Opens drawer
closeDrawers() Closes drawer

License

Copyright 2019 Jantz Carney

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Releases

No releases published

Packages

No packages published

Languages