当前位置:网站首页>短视频平台开发,依靠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实现侧滑菜单效果,更多内容欢迎关注之后的文章
边栏推荐
- [problem handled] -nvidia SMI command cannot obtain the GPU process number of its own container and the external GPU process number
- Note d'étude du DC: zéro dans le chapitre officiel - - Aperçu et introduction du processus de base
- Exploring the road of steam education innovation in the Internet Era
- 元宇宙为 VR/AR 带来的新机会
- MFC TCP communication server client demo notes vs2019
- flutter报错 -- The argument type ‘Function‘ can‘t be assigned to the parameter type ‘void Function()?‘
- 【多源bfs】934. Shortest Bridge
- Double position relay dls-5/2 dc220v
- Pre training / transfer learning of models
- System.CommandLine版CSRebot
猜你喜欢
随机推荐
Exploring the road of steam education innovation in the Internet Era
为什么要搭建个人博客
K210 site helmet
TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to
6月第4周榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
dc_labs--lab1的学习与总结
【Qt5-基础篇_1】从0开始,德天老师和你一起学习——窗口简介
ESP8266 RC522
Service grid ASM year end summary: how do end users use the service grid?
js中把数字转换成汉字输出
Solve idea:class' xxx 'not found in module' xxx‘
User defined annotation implementation verification
Docker deployment MySQL 8
Install redis database and download redis Desktop Manager in win11
Strictmode jamming and leakage detection -strictmode principle (2)
About vctk datasets
StrictMode分析Activity泄漏-StrictMode原理(3)
[Deepin] 常用集合
用recyclerReview展示Banner,很简单
基础知识之一——STA基础概述









