相信用过Google+的人都感到其应用的特效相当棒,本文将以超简单的形式来实现类似Google+列表的特效。仅仅写几行代码就可以实现奥。
由于众所周知的原因,很多人无法使用Google+应用。所以有必要让大家先看一看真面目。
P.S.找了很多的屏目录制软件都不行,并且没有4.4的机器,所以只能用最笨的方法录制了,请见谅哈。
1 2 3 4 5 6 7 8 9 | <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator" android:shareInterpolator="true"> <translate android:fromXDelta="0%" android:toXDelta="0%" android:fromYDelta="100%" android:toYDelta="0%" android:duration="400" /> </set> |
---|
1 2 3 4 5 6 7 8 9 | <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator" android:shareInterpolator="true"> <translate android:fromXDelta="0%" android:toXDelta="0%" android:fromYDelta="-100%" android:toYDelta="0%" android:duration="400" /> </set> |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | private int mLastPosition = -1; @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); int animResId; if (position > mLastPosition) { animResId = R.anim.from_bottom_to_top; } else { animResId = R.anim.from_top_to_bottom; } Animation animation = AnimationUtils.loadAnimation(getContext(), animResId); view.startAnimation(animation); mLastPosition = position; return view; } |
---|