element ui实现抽屉效果_抽屉效果的导航菜单

这篇博客介绍了如何在Android中实现抽屉效果的导航菜单,主要探讨了两种方法:1. 使用已废弃的SlidingDrawer;2. 使用推荐的DrawerLayout,并详细讲解了如何配置和使用DrawerLayout,包括设置抽屉内容、监听器以及处理抽屉的打开和关闭。示例代码展示了如何创建和控制DrawerLayout的行为。
摘要由CSDN通过智能技术生成

抽屉效果的导航菜单

看了很多应用,觉得这种侧滑的抽屉效果的菜单很好。

不用切换到另一个页面,也不用去按菜单的硬件按钮,直接在界面上一个按钮点击,菜单就滑出来,而且感觉能放很多东西。

关于实现,搜索了一下,有如下两种:

1.用SlidingDrawer:

但是不知道为什么这个类官方不建议再继续用了:

Deprecated since API level 17

2.用DrawerLayout:

Guide在这里:

库的引用

首先,Support Library里的,需要加上android-support-v4.jar这个包。

然后程序中用时在前面导入import android.support.v4.widget.DrawerLayout;

如果找不到这个类,首先用SDK Manager更新一下Android Support Library,然后在Android SDK\extras\android\support\v4路径下找到android-support-v4.jar,复制到项目的libs路径,将其Add to Build Path.

代码1

布局:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent" >

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/drawer_layout"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:id="@+id/content_frame"

android:layout_width="match_parent"

android:layout_height="match_parent" />

android:id="@+id/left_drawer"

android:layout_width="240dp"

android:layout_height="match_parent"

android:layout_gravity="left"

android:background="#111"

android:choiceMode="singleChoice"

android:divider="@android:color/transparent"

android:dividerHeight="0dp" />

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值