# SwipeDelMenuLayout [![](https://jitpack.io/v/mcxtzhang/SwipeDelMenuLayout.svg)](https://jitpack.io/#mcxtzhang/SwipeDelMenuLayout) 相关博文: 从0实现V1.0版本 http://blog.csdn.net/zxt0601/article/details/52303781 V1.2版本的更新和改动以及使用 http://blog.csdn.net/zxt0601/article/details/53157090 喜欢随手点个star 多谢 ## 在哪里找到我: 我的github: https://github.com/mcxtzhang 我的CSDN博客: http://blog.csdn.net/zxt0601 我的稀土掘金: http://gold.xitu.io/user/56de210b816dfa0052e66495 我的简书: http://www.jianshu.com/users/8e91ff99b072/timeline *** # 重要的话 开头说,not for the RecyclerView or ListView, for the Any ViewGroup. 本控件**不依赖任何**父布局,不是针对 RecyclerView、ListView,而是**任意的ViewGroup**里的childView都可以使用侧滑(删除)菜单。 # 概述 本控件从撸出来在项目使用至今已经过去7个月,距离第一次将它push至github上,也已经2月+。(之前,我发表过一篇文章。传送门:http://gold.xitu.io/entry/57d1115dbf22ec005f9593c6/detail, 里面详细描述了本控件V1.0版本是怎么实现的。) 期间有很多朋友在评论、issue里提出了一些**改进**意见,例如支持设置滑动方向(左右)、高仿QQ的交互、支持GridLayoutManager等,以及一些**bug**。已经被我**全部实、修复**。并且将其打包至jitpack,引入**更方便**。和第一版相比,改动挺多的。故将其整理,新发一版。 那么本文先从如何使用它讲起,然后介绍它包含的特性、支持的属性。最后就几个难点和冲突的解决进行讲解。 代码传送门:喜欢的话,随手点个star。多谢 https://github.com/mcxtzhang/SwipeDelMenuLayout 先上几个gif给各位看官感受一下最新版的魅力(以下版本都顺便展示了可选的双向滑动) 本控件最大魅力就是0耦合,所以先上配合我另一个库组装的效果(ItemDecorationIndexBar + SwipeMenuLayout): (ItemDecorationIndexBar : https://github.com/mcxtzhang/ItemDecorationIndexBar) ![image](https://github.com/mcxtzhang/SwipeDelMenuLayout/blob/master/gif/ItemDecorationIndexBar_SwipeDel.gif) 随便来个流式布局也不在话下: ![](https://github.com/mcxtzhang/SwipeDelMenuLayout/blob/master/gif/FlowSwipe.gif) Android Special Version (无阻塞式,侧滑菜单展开时,依然可以展开其他侧滑菜单,同时上一个菜单会自动关闭): ![image](https://github.com/mcxtzhang/SwipeDelMenuLayout/blob/master/gif/LinearLayoutManager1.gif) GridLayoutManager (和上图的代码比,只需修改RecyclerView的LayoutManager。): ![image](https://github.com/mcxtzhang/SwipeDelMenuLayout/blob/master/gif/grid.gif) LinearLayout (不需任何修改,连LinearLayout也可以简单的实现侧滑菜单): ![image](https://github.com/mcxtzhang/SwipeDelMenuLayout/blob/master/gif/linear.gif) iOS interaction (阻塞式交互,高仿QQ,侧滑菜单展开式,屏蔽其他ITEM所有操作): ![image](https://github.com/mcxtzhang/SwipeDelMenuLayout/blob/master/gif/iOS.gif) 在ViewPager中使用: ![image](https://github.com/mcxtzhang/SwipeDelMenuLayout/blob/master/gif/viewpager.gif) # 使用: Step 1. 在项目根build.gradle文件中增加JitPack仓库依赖。 ``` allprojects { repositories { ... maven { url "https://jitpack.io" } } } ``` Step 2. Add the dependency ``` dependencies { compile 'com.github.mcxtzhang:SwipeDelMenuLayout:V1.3.0' } ``` Step 3. 在需要侧滑删除的ContentItem外面套上本控件,在本控件内依次排列ContentItem、菜单即可: **至此 您就可以使用高仿IOS、QQ 侧滑删除菜单功能了** (侧滑菜单的点击事件等是通过设置的id取到,与其他控件一致,不再赘述) Demo里,我的ContentItem是一个TextView,那么我就在其外嵌套本控件,并且以侧滑菜单出现的顺序,依次排列菜单控件即可。 ```