Easy to implement Google Photos style multi-selection for RecyclerViews.

Min SDK   14
Latest Commit   2017-06-10 19:26:21
License   MIT

Github   https://github.com/afollestad/drag-select-recyclerview



Using app client to scan QR code to run Demo


Saint Paul, MN

A young, professional full-stack software engineer based in Minnesota. Also a drummer, rock/metal fan, and motorcycle/car enthusiast. Checkout my website!


FlabbyListView Android library to display a ListView whose cells are not rigid but flabby and react to ListView scroll.
SlidingLayout 实现类似微信WebView的上拉下拉弹跳效果和iOS的ListView的果冻效果。
Android-QuickSideBar 帮助快速查阅对应分组的侧边栏


Drag Select Recycler View

This library allows you to implement Google Photos style multi-selection in your apps! You start by long pressing an item in your list, then you drag your finger without letting go to select more.



You can download a sample APK or view it on Google Play!

Get it on Google Play

Gradle Dependency

jCenter Build Status License

The Gradle dependency is available via jCenter. jCenter is the default Maven repository used by Android Studio.


Add the following to your module's build.gradle file:

dependencies {
    // ... other dependencies
    compile 'com.afollestad:drag-select-recyclerview:1.0.0'


  1. Introduction
  2. DragSelectRecyclerView
    1. How to create a DragSelectRecyclerView in your layout. How to set it up from code.
  3. Adapter Implementation
    1. An example of how adapter's should be setup.
  4. User Activation, Initializing Drag Selection
    1. How drag selection mode is activated by a long press. How to maintain selected items through configuration changes, etc.
  5. Auto Scroll
    1. By default, this library will auto-scroll up or down if the user holds their finger at the top or bottom of the list during selection mode.


DragSelectRecyclerView is the main classes of this library.

This library will handle drag interception and auto scroll logic - if you drag to the top of the RecyclerView, the list will scroll up, and vice versa.


DragSelectRecyclerView replaces the regular RecyclerView in your layouts. It intercepts touch events when you tell if selection mode is active, and automatically reports to your adapter.

        android:scrollbars="vertical" />

Setup is basically the same as it would be for a regular RecyclerView. You just set a LayoutManager and RecyclerView.Adapter to it:

DragSelectRecyclerView list = (DragSelectRecyclerView) findViewById(R.id.list);
list.setLayoutManager(new GridLayoutManager(this, 3));

Adapter Implementation

You use regular RecyclerView.Adapter's with the DragSelectRecyclerView. However, it has to implement the IDragSelectAdapter interface:

public class MainAdapter extends RecyclerView.Adapter<MainAdapter.MainViewHolder>
      implements IDragSelectAdapter {

  public void setSelected(int index, boolean selected) {
    // 1. Make this index as selected in your implementation.
    // 2. Tell the RecyclerView.Adapter to render this item's changes.
  public boolean isIndexSelectable(int index) {
    // Return false if you don't want this position to be selectable.
    // Useful for items like section headers.
    return true;
  // The rest of your regular adapter overrides

Checkout the sample project for an in-depth example.

User Activation, Initializing Drag Selection

The library won't start selection mode unless you tell it to. You want the user to be able to active it. The click listener implementation setup in the adapter above will help with this.

public class MainActivity extends AppCompatActivity implements
      MainAdapter.ClickListener, DragSelectRecyclerViewAdapter.SelectionListener {

  private DragSelectRecyclerView listView;
  private MainAdapter adapter;

  protected void onCreate(Bundle savedInstanceState) {

    // Setup adapter and callbacks
    adapter = new MainAdapter(this);

    // Setup the recycler view
    listView = (DragSelectRecyclerView) findViewById(R.id.list);
        new GridLayoutManager(this, 

   * See the adapter in the sample project for a click listener implementation. Click listeners 
   * aren't provided by this library.
  public void onClick(int index) {
    // Single click will select or deselect an item

   * See the adapter in the sample project for a click listener implementation. Click listeners 
   * aren't provided by this library.
  public void onLongClick(int index) {
    // Initialize drag selection -- also selects the initial item
    listView.setDragSelectActive(true, index);

Auto Scroll

By default, this library will auto scroll. During drag selection, moving your finger to the top of the list will scroll up. Moving your finger to the bottom of the list will scroll down.

At the start of the activation point at the top or bottom, the list will scroll slowly. The further you move into the activation area, the faster it will scroll.

You can disable auto scroll, or change the activation hotspot from your layout XML:

    app:dsrv_autoScrollHotspotHeight="56dp" />

56dp is the default hotspot height, you can raise or lower it if necessary. Smaller hotspots will scroll quickly since there's not much room for velocity change.