Reputation: 33
I am trying animation on GridView
similar to this http://framerjs.com/examples/preview/#delayed-animations.framer. I tried slideUp animation on GridView
but all columns move at same point. I need it similar to the above link.
Upvotes: 2
Views: 9502
Reputation: 111
Use GridLayoutAnimationController for grid item animation.
Animation animation = AnimationUtils.loadAnimation(getContext(),R.anim.grid_item_anim);
GridLayoutAnimationController controller = new GridLayoutAnimationController(animation, .2f, .2f);
mGrid.setLayoutAnimation(controller);
grid_item_anim.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="1000"
android:fromYDelta="100%p"
android:interpolator="@android:anim/linear_interpolator"
android:toYDelta="0%p" />
</set>
add animate layout changes to true in your grid view layout
android:animateLayoutChanges="true"
Upvotes: 11
Reputation: 1085
Create a folder under "res" with name "anim" and inside "anim" create a xml file with name animation_move.xml(could be anyname).This app is using some animations in GridView .Social Stickers
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="5000"
android:fromYDelta="0%p"
android:interpolator="@android:anim/cycle_interpolator"
android:toYDelta="100%p" />
</set>
and in your adapter class,do initialization
Animation animation = AnimationUtils.loadAnimation(context, R.anim.animation_move);
and in getview function,suppose you are using images
picture = (ImageView) v.getTag(R.id.picture);
picture.setImageResource(item.drawableId);
picture.startAnimation(animation);
your getview function could be different but this code will give you hint.
Upvotes: 5