SwipeLayout实现滑动删除
SwipeLayout
我们可以用过这个实现向ios系统上类似于微信上删除对话框的功能,AndroidSwipeLayout(https://github.com/daimajia/AndroidSwipeLayout),顾名思义,Android平台上的滑动布局,是一个可以让我们很方便使用滑动的库,典型的应用就是侧滑删除与侧滑菜单。在android的开发中运用的场景也是很多。如图所示的效果。
1、配置:
在模块中添加引用:
compile "com.daimajia.swipelayout:library:1.2.0@aar"
compile 'com.android.support:recyclerview-v7:23.2.1'```
2、xml布局文件配置:
主布局中添加了一个RecyclerView来显示数据
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.androidswipelayoutdemo.MainActivity">
<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="center"
android:text="文本显示"
/>
<android.support.v7.widget.RecyclerView
android:layout_below="@id/tv"
android:id="@+id/mRecycleView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
然后在创建一个xml文件是适配器的布局也是swipelayout的布局
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/swipe_layout"
android:layout_height="wrap_content">
<LinearLayout
android:background="#66ddff00"
android:id="@+id/bottom_wrapper"