0
点赞
收藏
分享

微信扫一扫

超简单实现Google+列表特效

女侠展昭 2022-11-09 阅读 63


相信用过Google+的人都感到其应用的特效相当棒,本文将以超简单的形式来实现类似Google+列表的特效。仅仅写几行代码就可以实现奥。

特效真面目

由于众所周知的原因,很多人无法使用Google+应用。所以有必要让大家先看一看真面目。

P.S.找了很多的屏目录制软件都不行,并且没有4.4的机器,所以只能用最笨的方法录制了,请见谅哈。

特效动画

from_bottom_to_top.xml



<?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>

from_top_to_bottom.xml



<?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>

加入动画



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;
}

其他

  • 精彩绝伦的Android UI设计
  • 精通Android 3



举报

相关推荐

0 条评论