android 仿微信listview 控件,仿通讯录ListView小例子

本文介绍如何在Android中通过自定义Interpolator实现动画的反弹效果。通过设置插值器公式1.2-((x*1.55f)-1.1)^2,可以观察到动画在超过目标区域后反弹的细节。示例代码中提供了CustomInterpolator的实现,该类实现了Interpolator接口,并通过调整输入值来控制动画的加速度变化,从而达到反弹动画的效果。
摘要由CSDN通过智能技术生成

android:fromXDelta="100%p"

android:toXDelta="0"

android:duration="@android:integer/config_longAnimTime"

>

需要反弹的效果还得对Animation设定Interpolator(插值器),插值器的设定需要一些数学基础了,得找到合适的函数对动画速率进行修正.本例中使用的插值器代码如下:

package lab.sodino.list_quickaction;

import android.util.Log;

import android.view.animation.Interpolator;

/**

* @author Sodino E-mail:sodinoopen@hotmail.com

* @version Time:2011-5-3 下午08:02:01

*/

public class CustomInterpolator implements Interpolator {

/**

* @param input

* A value between 0 and 1.0 indicating our current point in the

* animation where 0 represents the start and 1.0 represents the

* end

* @return Returns The interpolation value. This value can be more than 1.0

* for Interpolators which overshoot their targets, or less than 0

* for Interpolators that undershoot their targets.

*/

public float getInterpolation(float input) {

Log.d("ANDROID_LAB", "input=" + input);

// 设定动画的加速度变化值.此例的效果是使用actionsLayout超过目标旋转区后再反弹回来.

// 插值计算公式: 1.2-((x*1.55f)-1.1)^2

// 画出函数图的话即可观察出动画执行过程中越过目标区再反弹的详细过程.

// x :0 <= v <= 1.0

// (x*1.55f) :0 <= v <= 1.55

// ((x*1.55f)-1.1) :-1.1 <= v <= 0.45

// ((x*1.55f)-1.1)^2 :0<= v <= 1.21

// 1.2-((x*1.55f)-1.1)^2 :-0.1 <= v <= 1.2

final float inner = (input * 1.55f) - 1.1f;

// 如果返回值为常量1的话,则相当于没有动画效果.

return 1.2f - inner * inner;

}

}

转载:http://www.adobex.com/android/source/details/00000359.htm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值