This library provides a way to create simple or complex drawer implementations in a single layout!
dependencies {
implementation 'com.creativesource:simpledrawerlayout:0.1.0'
}
<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">
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 |
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;
}
});
Method | Description |
---|---|
setNavigationItemSelectedListener (OnNavigationItemSelectedListener navigationListener) |
Sets drawer navigation item listener |
openDrawer(int gravity) |
Opens drawer |
closeDrawers() |
Closes drawer |
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.