-Apps with five or more top-level destinations
-Apps with two or more levels of navigation hierarchy
-Quick navigation between unrelated destinations
XML Code
<?xml version="1.0" encoding="utf-8"?> <nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout android:id="@+id/drawer" 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:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <nl.psdcompany.duonavigationdrawer.views.DuoMenuView android:tag="menu" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:fontFamily="@font/amita_regular" android:textSize="30sp" android:gravity="center" android:layout_width="match_parent" android:layout_height="130dp" android:text="Stylish Nav Drawer Menu" android:textColor="@color/white"/> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:gravity="center" android:orientation="vertical" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"> <TextView android:fontFamily="@font/gabriela_regular" android:textSize="16sp" android:layout_marginHorizontal="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="RBMJ Limited" android:textColor="@color/white"/> <TextView android:fontFamily="@font/gabriela_regular" android:textSize="16sp" android:layout_marginHorizontal="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="support@rbmjltd.xyz" android:textColor="@color/white"/> </LinearLayout> <de.hdodenhof.circleimageview.CircleImageView android:layout_marginRight="100dp" android:layout_width="100dp" android:layout_height="100dp" android:src="@drawable/logo"/> </LinearLayout> <LinearLayout android:id="@+id/ll_Home" android:gravity="center_vertical" android:layout_marginTop="50dp" android:layout_marginHorizontal="24dp" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/home" app:tint="@color/white" /> <TextView android:fontFamily="@font/my_font" android:textSize="16sp" android:layout_marginHorizontal="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Home" android:textColor="@color/white"/> </LinearLayout> <LinearLayout android:id="@+id/ll_Tips_Tricks" android:gravity="center_vertical" android:layout_marginTop="24dp" android:layout_marginHorizontal="24dp" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/profile" app:tint="@color/white" /> <TextView android:fontFamily="@font/my_font" android:textSize="16sp" android:layout_marginHorizontal="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Profile" android:textColor="@color/white"/> </LinearLayout> <LinearLayout android:id="@+id/ll_Steps" android:gravity="center_vertical" android:layout_marginTop="24dp" android:layout_marginHorizontal="24dp" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/setting" app:tint="@color/white" /> <TextView android:fontFamily="@font/my_font" android:textSize="16sp" android:layout_marginHorizontal="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Setting" android:textColor="@color/white"/> </LinearLayout> <LinearLayout android:id="@+id/ll_Logout" android:gravity="center_vertical" android:layout_marginTop="24dp" android:layout_marginHorizontal="24dp" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/logout" app:tint="@color/white" /> <TextView android:fontFamily="@font/my_font" android:textSize="16sp" android:layout_marginHorizontal="16dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Logout" android:textColor="@color/white"/> </LinearLayout> </LinearLayout> </nl.psdcompany.duonavigationdrawer.views.DuoMenuView> <androidx.cardview.widget.CardView android:tag="content" android:elevation="200dp" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="match_parent" android:layout_height="110dp" android:background="@drawable/header"/> <LinearLayout android:background="@color/background" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:background="@drawable/main_bg" android:layout_marginTop="120dp" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/frame" android:layout_marginTop="30dp"/> </LinearLayout> </LinearLayout> <androidx.appcompat.widget.Toolbar android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/toolbar"/> </RelativeLayout> </androidx.cardview.widget.CardView> </nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout>
Java Code
package com.rbmjltd.appName; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import android.os.Bundle; import android.view.View; import android.widget.LinearLayout; import nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout; import nl.psdcompany.duonavigationdrawer.widgets.DuoDrawerToggle; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private DuoDrawerLayout drawerLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); } private void init() { Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); drawerLayout = (DuoDrawerLayout) findViewById(R.id.drawer); DuoDrawerToggle drawerToggle = new DuoDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawerLayout.setDrawerListener(drawerToggle); drawerToggle.syncState(); View contentView = drawerLayout.getContentView(); View menuView = drawerLayout.getMenuView(); LinearLayout ll_Home = menuView.findViewById(R.id.ll_Home); LinearLayout ll_Tips_Tricks = menuView.findViewById(R.id.ll_Tips_Tricks); LinearLayout ll_Steps = menuView.findViewById(R.id.ll_Steps); LinearLayout ll_Logout = menuView.findViewById(R.id.ll_Logout); ll_Home.setOnClickListener(this); ll_Tips_Tricks.setOnClickListener(this); ll_Steps.setOnClickListener(this); ll_Logout.setOnClickListener(this); replace(new HomeFragment()); } @Override public void onClick(View view) { switch (view.getId()){ case R.id.ll_Home: replace(new HomeFragment(),"Home"); break; case R.id.ll_Tips_Tricks: replace(new ProfileFragment(),"Profile"); break; case R.id.ll_Steps: replace(new SettingFragment(),"setting"); break; case R.id.ll_Logout: replace(new LogOutFragment(),"Logout"); break; } drawerLayout.closeDrawer(); } private void replace(Fragment fragment, String s) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.frame,fragment); transaction.addToBackStack(s); transaction.commit(); } private void replace(Fragment fragment) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.frame,fragment); transaction.commit(); } }