首页 » Andorid » 临时分类 » 正文

SwipeMenuRecyclerView

SwipeMenu

A swipe menu for horizontal/vertical, support left/right and top/bottom directions, low coupling, can fast rapid integration into your project

Features

  • Support LinearLayoutManager、GridLayoutManager and StaggeredGridLayoutManager for RecyclerView (only horizontal)
  • Support ListView and GridView (only horizontal)
  • Support ScrollView (only horizontal and the [SwipeHorizontal/SwipeVertical]MenuLayout must be the direct child of ScrollView's direct child )
  • On-off swipe ability
  • Not intercept item touch event
  • Left/Right and Top/Bottom menu support, free switch

Preview

DEMO

Usage

Add to dependencies

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

Horizontal

Just use SwipeHorizontalMenuLayout, we use SwipeHorizontalMenuLayout ViewGroup to combine item content view and left/right(at least one) swipe menu








If you have so many items, you may be want to use our custom RecyclerView






Vertical

Just use SwipeVerticalMenuLayout, we use SwipeVerticalMenuLayout ViewGroup to combine item content view and top/bottom (at least one) swipe menu











        <Button />

        <Button />








More details please see the demo project

Listeners

We add a SwipeSwitchListener for actions like open/close

sml.setSwipeListener(new SwipeSwitchListener() {
    @Override
    public void beginMenuClosed(SwipeMenuLayout swipeMenuLayout) {
        Log.e(TAG, "left menu closed");
    }

    @Override
    public void beginMenuOpened(SwipeMenuLayout swipeMenuLayout) {
        Log.e(TAG, "left menu opened");
    }

    @Override
    public void endMenuClosed(SwipeMenuLayout swipeMenuLayout) {
        Log.e(TAG, "right menu closed");
    }

    @Override
    public void endMenuOpened(SwipeMenuLayout swipeMenuLayout) {
        Log.e(TAG, "right menu opened");
    }
});

If you case a few actions, just use SimpleSwipeSwitchListener

sml.setSwipeListener(new SimpleSwipeSwitchListener(){
    @Override
    public void beginMenuClosed(SwipeMenuLayout swipeMenuLayout) {
        Log.e(TAG, "left menu closed");
    }
});

We also add a SwipeFractionListener for complete fraction action

sml.setSwipeFractionListener(new SwipeFractionListener() {
    @Override
    public void beginMenuSwipeFraction(SwipeMenuLayout swipeMenuLayout, float fraction) {
        Log.e(TAG, "top menu swipe fraction:"+fraction);

    }

    @Override
    public void endMenuSwipeFraction(SwipeMenuLayout swipeMenuLayout, float fraction) {
        Log.e(TAG, "bottom menu swipe fraction:"+fraction);
    }
});

If you case a few actions, just use SimpleSwipeFractionListener

sml.setSwipeFractionListener(new SimpleSwipeFractionListener(){
    @Override
    public void beginMenuSwipeFraction(SwipeMenuLayout swipeMenuLayout, float fraction) {
        Log.e(TAG, "top menu swipe fraction:"+fraction);
    }
});

Custom

Supported custom attrs:

  • sml_scroller_duration Scroller duration(ms), sml:sml_scroller_duration="250"
  • sml_auto_open_percent Swipe menu auto open percent(relative to menu's width), sml:sml_auto_open_percent="0.5"
  • sml_scroller_interpolator Scroller open/close interpolation, sml:sml_scroller_interpolator="@android:anim/bounce_interpolator"







Thanks

Inspired by baoyongzhang/SwipeMenuListView

License

Copyright 2016 TUBB

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
下载 (0)

发表评论