当前位置:网站首页>短视频平台开发,依靠DrawerLayout实现侧滑菜单效果
短视频平台开发,依靠DrawerLayout实现侧滑菜单效果
2022-07-01 00:42:00 【云豹网络科技】
短视频平台开发,依靠DrawerLayout实现侧滑菜单效果
activity_main.xml
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<!-- 右边视图 -->
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- 左边菜单 -->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
然后在res文件夹里面添加一个menu菜单文件夹,已经添加的就不用添加了
上面的代码里面NavigationView里面有个 app:menu=”@menu/activity_main_drawer”对应如下:
添加一个菜单文件,名字随意,我的是activity_main_drawer.xml
activity_main_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_camera"
android:icon="@drawable/ic_menu_camera"
android:title="第一行" />
<item
android:id="@+id/nav_gallery"
android:icon="@drawable/ic_menu_gallery"
android:title="第二行" />
<item
android:id="@+id/nav_slideshow"
android:icon="@drawable/ic_menu_slideshow"
android:title="第三行" />
<item
android:id="@+id/nav_manage"
android:icon="@drawable/ic_menu_manage"
android:title="第四行" />
</group>
<item android:title="Communicate">
<menu>
<item
android:id="@+id/nav_share"
android:icon="@drawable/ic_menu_share"
android:title="第五行" />
<item
android:id="@+id/nav_send"
android:icon="@drawable/ic_menu_send"
android:title="第六行" />
</menu>
</item>
</menu>
以上就是 短视频平台开发,依靠DrawerLayout实现侧滑菜单效果,更多内容欢迎关注之后的文章
边栏推荐
- 友盟(软件异常实时监听的好帮手:Crash)接入教程(有点基础的小白最易学的教程)
- 1175. Prime Arrangements
- Principes de formation de la programmation robotique
- Visual studio 2019 shortcut notes
- Koa koa combine routes sub route management
- 尝试新的可能
- About the general input operation mode of unity
- 【模拟】922. Sort Array By Parity II
- 生意和投资的思考
- StrictMode分析Activity泄漏-StrictMode原理(3)
猜你喜欢
随机推荐
dc_ Study and summary of labs--lab1
小程序自定义宫格
流批一体在京东的探索与实践
微研所,微生物检验中常用的生化反应
微生物安全与健康,什么是生物处理?
Thinking brought by strictmode -strictmode principle (5)
mysql插入\更新前+判断条件
Unknown database连接数据库错误
奇偶链表[链表操作的两种大方向]
友盟(软件异常实时监听的好帮手:Crash)接入教程(有点基础的小白最易学的教程)
【office办公-pdf篇】pdf合并与拆分让我们摆脱付费软件的功能限制好不好
Open3D 点云包围盒
图的连通性基础
QT5-布局在创作中的理解应用
About vctk datasets
uniapp官方组件点击item无效,解决方案
visual studio 2019 快捷键备忘
Strictmode analysis activity leakage -strictmode principle (3)
WIN11中MathType编辑中“打开数学输入面板”是灰色不可编辑
K210 access control complete









