Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Custom Navigation Drawer Library for Android

License

NotificationsYou must be signed in to change notification settings

shrikanth7698/Custom-Navigation-Drawer

Repository files navigation

alt textforthebadge

forthebadge

forthebadge

Buy Me a Coffee at ko-fi.com

It has smooth zoom-in, zoom-out animation when switched from one fragment to another.

Repo no longer being maintained.

Android Arsenal

Version

Installation

  • Gradle

    Add it in your root build.gradle at the end of repositories:

    allprojects { repositories {... maven { url'https://jitpack.io' } } }

    Add the dependency in your app build.gradle

    dependencies {         compile'com.github.shrikanth7698:Custom-Navigation-Drawer:v0.0.1' }
  • Maven

    Add the JitPack repository to your build file

    <repositories><repository><id>jitpack.io</id><url>https://jitpack.io</url></repository></repositories>

    Add the dependency

    <dependency><groupId>com.github.shrikanth7698</groupId><artifactId>Custom-Navigation-Drawer</artifactId><version>v0.0.1</version></dependency>

Usage

Drop the Custom Navigation Drawer in your XML layout as is shown below:

    <com.shrikanthravi.customnavigationdrawer2.widget.SNavigationDrawerandroid:layout_width="match_parent"android:layout_height="match_parent"android:id="@+id/navigationDrawer">        <FrameLayoutandroid:id="@+id/frameLayout"android:layout_width="match_parent"android:layout_height="match_parent"/>    </com.shrikanthravi.customnavigationdrawer2.widget.SNavigationDrawer>

And then in your Activity or fragment

//Global DeclarationSNavigationDrawersNavigationDrawer;ClassfragmentClass;publicstaticFragmentfragment;//Inside onCreate()sNavigationDrawer =findViewById(R.id.navigationDrawer);//Creating a list of menu ItemsList<MenuItem>menuItems =newArrayList<>();//Use the MenuItem given by this library and not the default one.//First parameter is the title of the menu item and then the second parameter is the image which will be the background of the menu item.menuItems.add(newMenuItem("News",R.drawable.news_bg));menuItems.add(newMenuItem("Feed",R.drawable.feed_bg));menuItems.add(newMenuItem("Messages",R.drawable.message_bg));menuItems.add(newMenuItem("Music",R.drawable.music_bg));//then add them to navigation drawersNavigationDrawer.setMenuItemList(menuItems);fragmentClass =NewsFragment.class;try {fragment = (Fragment)fragmentClass.newInstance();        }catch (Exceptione) {e.printStackTrace();        }if (fragment !=null) {FragmentManagerfragmentManager =getSupportFragmentManager();fragmentManager.beginTransaction().setCustomAnimations(android.R.animator.fade_in,android.R.animator.fade_out).replace(R.id.frameLayout,fragment).commit();        }//Listener to handle the menu item click. It returns the position of the menu item clicked. Based on that you can switch between the fragments.sNavigationDrawer.setOnMenuItemClickListener(newSNavigationDrawer.OnMenuItemClickListener() {@OverridepublicvoidonMenuItemClicked(intposition) {System.out.println("Position "+position);switch (position){case0:{fragmentClass =NewsFragment.class;break;                    }case1:{fragmentClass =FeedFragment.class;break;                    }case2:{fragmentClass =MessagesFragment.class;break;                    }case3:{fragmentClass =MusicFragment.class;break;                    }                }//Listener for drawer events such as opening and closing.sNavigationDrawer.setDrawerListener(newSNavigationDrawer.DrawerListener() {@OverridepublicvoidonDrawerOpened() {                    }@OverridepublicvoidonDrawerOpening(){                    }@OverridepublicvoidonDrawerClosing(){System.out.println("Drawer closed");try {fragment = (Fragment)fragmentClass.newInstance();                        }catch (Exceptione) {e.printStackTrace();                        }if (fragment !=null) {FragmentManagerfragmentManager =getSupportFragmentManager();fragmentManager.beginTransaction().setCustomAnimations(android.R.animator.fade_in,android.R.animator.fade_out).replace(R.id.frameLayout,fragment).commit();                        }                    }@OverridepublicvoidonDrawerClosed() {                    }@OverridepublicvoidonDrawerStateChanged(intnewState) {System.out.println("State "+newState);                    }                });            }        });

Customization

    <com.shrikanthravi.customnavigationdrawer2.widget.SNavigationDrawerandroid:layout_width="match_parent"android:layout_height="match_parent"app:navigationDrawerBackgroundColor="#151515"app:appbarTitleTextColor="@android:color/white"app:HamMenuIconTintColor="@android:color/white"app:appbarColor="@android:color/black"app:primaryMenuItemTextColor="@android:color/white"app:secondaryMenuItemTextColor="@android:color/white"app:appbarTitleTextSize="7sp"app:primaryMenuItemTextSize="7sp"app:secondaryMenuItemTextSize="7sp"android:id="@+id/navigationDrawer">        <FrameLayoutandroid:id="@+id/frameLayout"android:background="@android:color/black"android:layout_width="match_parent"android:layout_height="match_parent"/>    </com.shrikanthravi.customnavigationdrawer2.widget.SNavigationDrawer>

Developed by

License

MIT LicenseCopyright (c) 2018 Shrikanth RaviPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.

About

Custom Navigation Drawer Library for Android

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp