I wanted to understand what ListViewAnimations
is (a component, a Framework?) and how it works.
I wanted to understand what ListViewAnimations
is (a component, a Framework?) and how it works.
ListViewAnimations
is a free code library for Android that allows you to add animations to ListView
easily, as can be seen in the example:
You can download and check usage tutorials, as well as more information this link .
The library consists of separate modules:
lib-core
: The library core also contains appearence animations (< in> fade-in ). lib-manipulation
: contains manipulations of ListView
items, such as "Swipe-to-Hide" and "Drag-and-Drop" (famous < in> Drag-and-Drop ) lib-core-slh
: An extension of lib-core
to support StickyListHeaders
. Example use StickyListHeaders
Nowyouhavethreeoptions:
Addthefollowinginyourbuild.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'}
Oryoucandownloadsomefiles:
The .jar files should be added to your libs
folder or added as external jars in the build path of your project.
Or you can also add the following to your pom.xml
:
<dependency>
<groupId>com.nhaarman.listviewanimations</groupId>
<artifactId>lib-core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.nhaarman.listviewanimations</groupId>
<artifactId>lib-manipulation</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.nhaarman.listviewanimations</groupId>
<artifactId>lib-core-slh</artifactId>
<version>3.1.0</version>
</dependency>
Now that you've installed everything, let's go to the animations in a ListView
.
1. Appearance animations (fade-in)
This animation serves as a fade-in (animation on the opacity of an object or media, increasing as a function of time).
MyAdaptermyAdapter=newMyAdapter();AlphaInAnimationAdapteranimationAdapter=newAlphaInAnimationAdapter(myAdapter);animationAdapter.setAbsListView(mListView);mListView.setAdapter(animationAdapter);
YoucancreateyourownAnimationAdapter
,oruseoneofthepredefinedones,whichare:
AlphaAnimationAdapter
ScaleInAnimationAdapter
SwingBottomInAnimationAdapter
SwingLeftInAnimationAdapter
SwingRightInAnimationAdapter
Intheexample,AlphaInAnimationAdapter
wasused.
2.DynamicListView
DynamicListView
isaclassthathaseffectslikeDrag-and-Drop,Swype-to-Dismiss,andanimationstoremove,move,andinsertitems.Itwasmadetomatchthedescriptionsaboveconveniently.
FirstincludethisinyourXMLlayout:
<com.nhaarman.listviewanimations.itemmanipulation.DynamicListViewandroid:id="@+id/dynamiclistview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
3. Drag and Drop
In order to do this, call by enableDragAndDrop()
in your DynamicListView
and seven which items will be eligible to be caught, this you can use TouchViewDraggableManager
:
mDynamicListView.enableDragAndDrop();
mDynamicListView.setDraggableManager(new TouchViewDraggableManager());
You can also start drag using startDraggin(int)
, for example in a 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: This feature is only possible on devices that run ICS (API 14) or higher.
For other purposes, you can take a look on this page in English .
Retired from here - under free translation
I did not find anything about ListViewAnimation
in the official documentation, you're probably quoting the ListViewAnimations , which is a lib that helps you in animations related to ListViews
and GridViews
. As for usage, you have a example application in the repository, integration is reasonably well exemplified.