AndroidStudio之侧滑菜单实现
基本侧滑菜单实现:

1.去掉系统自带的ActionBar
1.修改MainActivity默认的Style,在values/styles.xml中修改style为:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
2.设置界面的布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerlayout_drawer">
<!--DrawerLayout最好为界面的根布局-->
<!--主内容区的布局代码要放在侧滑菜单布局的前面,-->
<RelativeLayout
android:id="@+id/drawerlayout_main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/drawer_layout_rl_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background=
Android Studio 实现侧滑菜单(DrawerLayout)

本文介绍了如何在Android Studio中实现侧滑菜单,包括基本的侧滑菜单实现步骤,如移除ActionBar,设置布局和监听,以及升级版侧滑菜单的设计,涉及到DrawerLayout、头部布局和菜单内容的配置。
最低0.47元/天 解锁文章
1581





