groovy
implementation 'androidx.drawerlayout:drawerlayout:1.1.0'
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
<RelativeLayout
android:id="@+id/slide_menu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start">
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
public class MainActivity extends AppCompatActivity {
private DrawerLayout drawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
drawerLayout = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawerLayout, R.string.open_navigation_drawer, R.string.close_navigation_drawer);
drawerLayout.addDrawerListener(toggle);
toggle.syncState();
}
}