前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >超简单实现Google+列表特效

超简单实现Google+列表特效

作者头像
技术小黑屋
发布2018-09-04 16:52:52
3840
发布2018-09-04 16:52:52
举报
文章被收录于专栏:技术小黑屋技术小黑屋

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

特效真面目

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

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

特效动画

from_bottom_to_top.xml

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>

from_top_to_bottom.xml

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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 特效真面目
  • 特效动画
    • from_bottom_to_top.xml
      • from_top_to_bottom.xml
      • 加入动画
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档