List View Animations - Free

  • List View Animations,  List View Animations Library, Android Library
  • List View Animations,  List View Animations Library, Android Library
  • List View Animations,  List View Animations Library, Android Library
  • List View Animations,  List View Animations Library, Android Library
  • Description

  • change log

  • faq

  • Comments

  • List View Animation

    ListViewAnimations is an Open Source Android library that allows developers to easily create ListViews with animations. Feel free to use it all you want in your Android apps provided that you cite this project and include the license in your app.

    Setup

    The library consists of separate modules:

    • lib-core: The core of the library, and contains appearance animations.
    • lib-manipulation: Contains the item manipulation options, such as Swipe-to-Dismiss, and Drag-and-Drop.
    • lib-core-slh: An extension of lib-core to support StickyListHeaders.

    When using lib-manipulation or lib-core-slh, lib-core is included as well.

    Add the following to your build.gradle:

    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
        compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
        compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
    }
    

    or

    Add the .jar files to your project's libs folder, or add them as external jars to your project's build path.

    or

    Add the following to your

    
        com.nhaarman.listviewanimations
        lib-core
        3.1.0
    
    
        com.nhaarman.listviewanimations
        lib-manipulation
        3.1.0
    
    
        com.nhaarman.listviewanimations
        lib-core-slh
        3.1.0
    
    

    Appearance animations

    The classes in the com.nhaarman.listviewanimations.appearance package provide a way for you to add more fancyness to your ListViews when showing data for the first time. Instead of snapping the items into view, the AnimationAdapter class lets you gradually present your items to the user:


    To implement this behaviour, you need to wrap your original adapter in an AlphaInAnimationAdapter:

     MyAdapter myAdapter = new MyAdapter();
    AlphaInAnimationAdapter animationAdapter = new AlphaInAnimationAdapter(myAdapter);
    animationAdapter.setAbsListView(mListView);
    mListView.setAdapter(animationAdapter);
     
     

    You can create your own AnimationAdapter implementation, or use one of the predefined ones:

    
        AlphaAnimationAdapter
        ScaleInAnimationAdapter
        SwingBottomInAnimationAdapter
        SwingLeftInAnimationAdapter
        SwingRightInAnimationAdapter
    
     


    DynamicListView

    The DynamicListView is a convenience class which provides drag and drop, swipe to dismiss and insertion animation functionality. It has been designed to combine these features in a most optimal way:

    To use the DynamicListView, include the following in your xml layout:




    Drag and drop

    To enable drag and drop, simply call enableDragAndDrop() on your DynamicListView, and specify when items are draggable. To specify a child view which can be touched to initiate a drag, you can use a TouchViewDraggableManager:

    mDynamicListView.enableDragAndDrop();
    mDynamicListView.setDraggableManager(new TouchViewDraggableManager(R.id.itemrow_gripview));
    


    You can also initiate a drag by calling startDragging(int), for example in an OnItemLongClickListener:

    mDynamicListView.enableDragAndDrop();
    mDynamicListView.setOnItemLongClickListener(
        new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(final AdapterView parent, final View view,
                                           final int position, final long id) {
                mDynamicListView.startDragging(position);
                return true;
            }
        }
    );
    


    Note that drag and drop functionality is only available on devices running ICS (API 14) and above.



    Swipe to dismiss

    To enable swipe to dismiss, call enableSwipeToDismiss(OnDismissCallback) on your DynamicListView. The OnDismissCallback you must supply is notified of dismissed items, and is responsible for deleting those items from the dataset:



    mDynamicListView.enableSwipeToDismiss(
        new OnDismissCallback() {
            @Override
            public void onDismiss(@NonNull final ViewGroup listView, @NonNull final int[] reverseSortedPositions) {
                for (int position : reverseSortedPositions) {
                    mAdapter.remove(position);
                }
            }
        }
    );
    


    Swipe to dismiss with contextual undo

    To enable swipe to dismiss with contextual undo, you can wrap your adapter in either a SimpleSwipeUndoAdapter, or a TimedUndoAdapter. The latter will automatically dismiss an item after a while when it has been brought into the undo state.


    MyAdapter myAdapter = new MyAdapter();
    SimpleSwipeUndoAdapter swipeUndoAdapter = new SimpleSwipeUndoAdapter(myAdapter, MyActivity.this,
        new OnDismissCallback() {
            @Override
            public void onDismiss(@NonNull final ViewGroup listView, @NonNull final int[] reverseSortedPositions) {
                for (int position : reverseSortedPositions) {
                    mAdapter.remove(position);
                }
            }
        }
    );
    swipeUndoAdapter.setAbsListView(mDynamicListView);
    mDynamicListView.setAdapter(swipeUndoAdapter);
    mDynamicListView.enableSimpleSwipeUndo();
    
    


    Animate addition

    The DynamicListView can also animate the addition of items in your dataset. To use this functionality, simply let your adapter implement Insertable, and call one of the insert methods on the DynamicListView:


    MyInsertableAdapter myAdapter = new MyInsertableAdapter(); // MyInsertableAdapter implements Insertable
    mDynamicListView.setAdapter(myAdapter);
    mDynamicListView.insert(0, myItem); // myItem is of the type the adapter represents.
    


    StickyListHeaders

    ListViewAnimations also supports appearance animations on StickyListHeaderListViews. You must wrap your AnimationAdapter in a StickyListHeadersAdapterDecorator:

    StickyListHeadersListView listView = (...);
    AlphaInAnimationAdapter animationAdapter = new AlphaInAnimationAdapter(adapter);
    StickyListHeadersAdapterDecorator stickyListHeadersAdapterDecorator = new StickyListHeadersAdapterDecorator(animationAdapter);
    stickyListHeadersAdapterDecorator.setStickyListHeadersListView(listView);
    listView.setAdapter(stickyListHeadersAdapterDecorator);
    


    Just like with the normal ListView, you can use any implementation of the AnimationAdapter class.

    Features

    ListViewAnimations provides the following features:

    • Appearance animations for items in ListViews, GridViews, other AbsListViews;
      • Built in animations include Alpha, SwingRightIn, SwingLeftIn, SwingBottomIn, SwingRightIn and ScaleIn.
      • Other animations can easily be added
      • StickyListHeaders is supported, other implementations can easily be added.
    • Swipe-to-Dismiss, Swipe-To-Dismiss with contextual undo;
    • Drag-and-Drop reordering;
    • Animate addition of items;
    • Smoothly expand your items to reveal more content;
  • There is no Related Products
  • There is no Change Log content
  • There is no FAQ