Coder Social home page Coder Social logo

swipemenurecyclerview's Introduction

SwipeMenuRecyclerView

A swipe menu for RecyclerView, low coupling, can fast rapid integration into your project

DEMO

DEMO

Usage

Add to dependencies

dependencies {
    compile 'com.tubb.smrv:swipemenu-recyclerview:3.0.2'
}

Step 1

Use SwipeMenuLayout, we use SwipeMenuLayout ViewGroup to combine item content view and swipe menu

<?xml version="1.0" encoding="utf-8"?>
<com.tubb.smrv.SwipeMenuLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <!-- item content view, the id must be (smContentView) -->
    <include android:id="@id/smContentView" layout="@layout/item_simple_content"/>
    <!-- item swipe menu, the id must be (smMenuView) -->
    <include android:id="@id/smMenuView" layout="@layout/item_simple_menu"/>
</com.tubb.smrv.SwipeMenuLayout>

Step 2

Just use our custom RecyclerView

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
    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="${relativePackage}.${activityClass}"
    android:id="@+id/swipeRefreshLayout">

    <com.tubb.smrv.SwipeMenuRecyclerView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</android.support.v4.widget.SwipeRefreshLayout>

More details please see the demo project.

Custom

You can on or off swipe feature, and set open/close Interpolator in onBindViewHolder(RecyclerView.ViewHolder vh, int position) method

itemView.setSwipeEnable(swipeEnable);
itemView.setOpenInterpolator(mRecyclerView.getOpenInterpolator());
itemView.setCloseInterpolator(mRecyclerView.getCloseInterpolator());

We add anim_duration attr to custom swipe animation duration, default is 500ms

<?xml version="1.0" encoding="utf-8"?>
<com.tubb.smrv.SwipeMenuLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:swipemenu="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    swipemenu:anim_duration="300">

</com.tubb.smrv.SwipeMenuLayout>

Features

Support LinearLayoutManager、GridLayoutManager and StaggeredGridLayoutManager for RecyclerView
On-off swipe ability
Not intercept item touch event
Good expansibility, we only override onInterceptTouchEvent(MotionEvent ev) method of RecyclerView

swipemenurecyclerview's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.