implementation 'androidx.drawerlayout:drawerlayout:1.1.0'
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"
android:layout_gravity="start">
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</androidx.drawerlayout.widget.DrawerLayout>
Button btnOpenDrawer = findViewById(R.id.btn_open_drawer);
btnOpenDrawer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
drawerLayout.openDrawer(Gravity.START);
}
});