How to implement google + listview animation

I want to implement an animation experience like google + listview. When the user moves the list, each item that was first loaded into the listview will start the animation. I am trying to add animation to the getview method to animate each element, but I want to confirm if this method is a good method, and I need to extend the listview class to finish this? So please give me some tips or some examples like google + listview. Many thanks:)

+7
source share
2 answers

You do not need to extend the ListView class.

Here is the Android library that implemented ListView animations similar to Google plus.

GenericBaseAdapter.java

GPlusListAdapter.java

MainActivity.java

How it works, in the getView adapter getView it animates the view if it is recently loaded.
(Thus, he extended the Adapter, not the ListView, to make the animation.)

You can also download the app apk example from the link sugared-list-animations-sample

+15
source

Google Plus-style ListView lists are all the evil these days on Android due to the poor animation displayed when presenting data. When a user scrolls down, new elements come to life and, frankly, they look amazing up_from_bottom.xml

  <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="@android:anim/decelerate_interpolator"> <translate android:fromXDelta="0%" android:toXDelta="0%" android:fromYDelta="100%" android:toYDelta="0%" android:duration="400" /> </set> 

Down from the top down_from_top.xml

  <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="@android:anim/decelerate_interpolator"> <translate android:fromXDelta="0%" android:toXDelta="0%" android:fromYDelta="-100%" android:toYDelta="0%" android:duration="400" /> </set> 

In the list of class adapters

  private int lastPosition = -1; @Override public View getView(int position, View convertView, ViewGroup parent) { //Load your view, populate it, etc... View view = ...; Animation animation = AnimationUtils.loadAnimation(getContext(), (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top); view.startAnimation(animation); lastPosition = position; return view; } 

copied from http://kylewbanks.com/blog/Implementing-Google-Plus-Style-ListView-Animations-on-Android

+2
source

All Articles