Skip to content

Instantly share code, notes, and snippets.

@sbelloz
Created January 9, 2015 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbelloz/8810247f1bdefef6abe4 to your computer and use it in GitHub Desktop.
Save sbelloz/8810247f1bdefef6abe4 to your computer and use it in GitHub Desktop.
Google+ Listview Animation
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import it.tgs.wow.light.R;
/**
* Created with IntelliJ IDEA.
* User: SimoneBellotti
* Date: 09/01/2015
* Time: 12.11
*/
public class GooglePlusAdapter
extends ArrayAdapter<Object> {
public GooglePlusAdapter(Context context, Object[] objects) {
super(context, android.R.layout.simple_list_item_1, objects);
}
private int lastPosition = -1;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//Doing inflating and user ViewHolder pattern
//After inflating animate the item
if (position > lastPosition) {
convertView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.slide_up));
Animator animator = AnimatorInflater.loadAnimator(getContext(), R.animator.rotate_animation);
animator.setTarget(convertView);
animator.start();
lastPosition = position;
}
return convertView;
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 Ahmed Nammari -->
<!-- Licensed under the Apache License, Version 2.0 (the "License"); -->
<!-- you may not use this file except in compliance with the License. -->
<!-- You may obtain a copy of the License at -->
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- Unless required by applicable law or agreed to in writing, software -->
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<!-- See the License for the specific language governing permissions and -->
<!-- limitations under the License. -->
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="800"
android:interpolator="@android:anim/decelerate_interpolator"
android:propertyName="rotationX"
android:repeatCount="0"
android:valueFrom="45"
android:valueTo="0"
android:valueType="floatType" />
<set xmlns:android="http://schemas.android.com/apk/res/android"
>
<translate
android:duration="600"
android:fromYDelta="30%p"
android:toYDelta="0" />
<alpha
android:duration="600"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment