A drag-and-drop scrolling grid view for Android

Overview

DraggableGridView

a drag-and-drop scrolling grid view for Android

Including in your project

To start using DraggableGridView:

  • Place libs/DraggableGridView.jar into your project's directory and add it to the build path (www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29)

  • Add an import to the activity you'd like to use it in: import com.animoto.android.views.*;

  • Add the view to your activity's layout XML and save it:

    <com.animoto.android.views.DraggableGridView android:id="@+id/dgv" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true">
    </com.animoto.android.views.DraggableGridView>
  • Obtain a reference to the view to use in code:

    public class DraggableGridViewSampleActivity extends Activity {
      DraggableGridView dgv;
    	
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
    
          dgv = ((DraggableGridView)findViewById(R.id.dgv));
      }
  • You're done! You can start adding any type of view you'd like.

    TextView tv = new TextView(this);
    tv.setText("Hello world!");
    dgv.addView(tv);

Features

  • Tap and hold a view to begin moving it! Drag it between other views to rearrange them, and drop them in place.

  • Scales nicely to any screen size or resolution

  • Animates smoothly to indicate the rearrangement of children

  • Performs well, even with hundreds of children

  • Becomes scrollable when it contains more children than are visible

  • Can scroll even when a child is being dragged: just bring it to the very top or bottom

  • Easy to modify or extend!

The Sample Project

The included project is an Android version of magnetic poetry, which you may have seen covering an eccentric friend's refrigerator. It creates an OnRearrangeListener for its DraggableGridView which manipulates an ArrayList of strings.

If you'd rather not have to separately keep track of the grid's elements, I suggest creating your own type of View that contains any information you need about the children and collecting this information from the DraggableGridView when you need it:

String[] words = new String[dgv.getChildCount()];
for (int i = 0; i < words.length; i++)
    words[i] = ((CustomView)dgv.getChildAt(i)).word;

To Do

  • Remove scrolling timer

  • Improve performance

Notes

  • This was developed targeting Android 2.2 (API level 8), though I'm sure it can be made to work on lower versions.

  • The sample project's main activity doesn't handle onConfigurationChanged, so it will restart if the screen orientation changes. I'll fix this soon, but it's not particularly important.

  • DraggableGridView and all associated code are © 2011, Animoto Inc, available under the Apache License, Version 2.0.

  • Check us out at www.animoto.com !

You might also like...
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.

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

A GridView which can addHeaderView and addFooterView
A GridView which can addHeaderView and addFooterView

Please follow me on GitHub, I need your support Github: https://github.com/liaohuqiu twitter: https://twitter.com/liaohuqiu 中文版文档 GridView with Header

. Android library that integrate sticky section headers in your RecyclerView

recyclerview-stickyheaders Recyclerview-stickyheaders is an Android library that makes it easy to integrate section headers in your RecyclerView. Thes

An android library for section headers that stick to the top
An android library for section headers that stick to the top

StickyListHeaders StickyListHeaders is an Android library that makes it easy to integrate section headers in your ListView. These section headers stic

Android library to achieve in an easy way, the behaviour of the home page in the Expedia app, with a pair of auto-scroll circular parallax ListViews.
Android library to achieve in an easy way, the behaviour of the home page in the Expedia app, with a pair of auto-scroll circular parallax ListViews.

ListBuddies This library is not maintained anymore and there will be no further releases Android library of a pair of auto-scroll circular parallax Li

Android library to observe scroll events on scrollable views.
Android library to observe scroll events on scrollable views.

Android-ObservableScrollView Android library to observe scroll events on scrollable views. It's easy to interact with the Toolbar introduced in Androi

An Android Animation library which easily add itemanimator to RecyclerView items.
An Android Animation library which easily add itemanimator to RecyclerView items.

RecyclerView Animators RecyclerView Animators is an Android library that allows developers to easily create RecyclerView with animations. Please feel

Android library providing simple way to control divider items (ItemDecoration) of RecyclerView
Android library providing simple way to control divider items (ItemDecoration) of RecyclerView

RecyclerView-FlexibleDivider Android library providing simple way to control divider items of RecyclerView Release Note [Release Note] (https://github

AndroidTreeView. TreeView implementation for android
AndroidTreeView. TreeView implementation for android

AndroidTreeView Recent changes 2D scrolling mode added, keep in mind this comes with few limitations: you won't be able not place views on right side

Owner
Tom Quinn
Formerly of @facebook, @google, and @animoto.
Tom Quinn
RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)

Advanced RecyclerView This RecyclerView extension library provides Google's Inbox app like swiping, Play Music app like drag-and-drop sorting and expa

Haruki Hasegawa 5.2k Dec 23, 2022
An Android staggered grid view which supports multiple columns with rows of varying sizes.

AndroidStaggeredGrid ##Notice - Deprecated - 09-2015 This library has been deprecated. We will no longer be shipping any updates or approving communit

Etsy, Inc. 4.8k Dec 29, 2022
Kotlin way of building RecyclerView Adapter 🧩. You do not have to write RecyclerView Adapters again and again and suffer from handling of different view types. Kiel will help you.

Kiel Kiel is a RecyclerView.Adapter with a minimalistic and convenient Kotlin DSL which provides utility on top of Android's normal RecyclerView.Adapt

ibrahim yilmaz 370 Jan 2, 2023
Android library defining adapter classes of RecyclerView to manage multiple view types

RecyclerView-MultipleViewTypeAdapter RecyclerView adapter classes for managing multiple view types Release Note [Release Note] (https://github.com/yqr

Yoshihito Ikeda 414 Nov 21, 2022
A modified version of Android's experimental StaggeredGridView. Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore.

StaggeredGridView Introduction This is a modified version of Android's experimental StaggeredGridView. The StaggeredGridView allows the user to create

Maurycy Wojtowicz 1.7k Nov 28, 2022
Android library to display a ListView whose cells are not rigid but flabby and react to ListView scroll.

FlabbyListView This library is not maintained anymore and there will be no further releases Android library to display a ListView which cells are not

JPARDOGO 762 Nov 23, 2022
An Android custom ListView and ScrollView with pull to zoom-in.

PullZoomView An Android custom ListView and ScrollView with pull to zoom-in. Features Set ZoomView enable Add HeaderView Custom ZoomView Parallax or N

Frank-Zhu 2.3k Dec 26, 2022
Android ListView that mimics a GridView with asymmetric items. Supports items with row span and column span

AsymmetricGridView An Android custom ListView that implements multiple columns and variable sized elements. Please note that this is currently in a pr

Felipe Lima 1.8k Jan 7, 2023
A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.

RecyclerViewSwipeDismiss A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView. Preview How to use Add these lines to yo

xcodebuild 431 Nov 23, 2022
*** WARNING: This library is no longer maintained *** An easy way to add a simple 'swipe-and-do-something' behavior to your `RecyclerView` items. Just like in Gmail or Inbox apps.

SwipeToAction An easy way to add a simple 'swipe-and-do-something' behavior to your RecyclerView items. Just like in Gmail or Inbox apps. Integration

Victor Calvello 223 Nov 16, 2022