I have a listView with about 20 items (dynamic items). I want to animate these items first they show up to user. something like Google+ cards. There are some points that I want to achieve:
Up to now I have tried:
I searched a lot but couldn't come along with a solution.
By the way, I prefer not to use external libraries. I have seen this before.
Thanks.
I've just tried this and it seems to meet all of your requirements:
boolean[] animationStates;
public void YourConstructor(...) {
...
animationStates = new boolean[data.size()];
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// (Re)Use the convertView
if (convertView == null) {
convertView = mInflater.inflate(R.layout.popup_list_item, parent, false);
if (!animationStates[position]) {
Log.e("TAG", "Animating item no: " + position);
animationStates[position] = true;
Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.fade_in);
animation.setStartOffset(position*500);
convertView.startAnimation(animation);
}
}
// Use convertView here
return convertView;
}
Here's my fade_in.xml file if you're interested:
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha
android:duration="1000"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
</set>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With