12.15 PullDoorView中Scroller

参考:

http://blog.csdn.net/liuhe688/article/details/6660823

http://blog.csdn.net/manymore13/article/details/12219687


PullDoorView中有一段代码:

  1. // 这个Interpolator你可以设置别的 我这里选择的是有弹跳效果的Interpolator  
  2.         Interpolator polator = new BounceInterpolator();  
  3.         mScroller = new Scroller(mContext, polator);  
BounceInterpolator是一个插值器,可用于Scroller、view、animation、

public void negative(View v) {  
        Animation anim = new RotateAnimation(currAngle, currAngle - 180, Animation.RELATIVE_TO_SELF, 0.5f,  
                Animation.RELATIVE_TO_SELF, 0.5f);  
        /** 匀速插值器 */  
        LinearInterpolator lir = new LinearInterpolator();  
        anim.setInterpolator(lir);  
        anim.setDuration(1000);  
        /** 动画完成后不恢复原状 */  
        anim.setFillAfter(true);  
        currAngle -= 180;  
        if (currAngle < -360) {  
            currAngle = currAngle + 360;  
        }  
        piechart.startAnimation(anim);  
    }  




动画定义文件/res/anim/scale.xml如下:
[html] view plaincopy
<?xml version="1.0" encoding="utf-8"?>  
<set xmlns:android="http://schemas.android.com/apk/res/android"  
    android:interpolator="@android:anim/bounce_interpolator">  
    <scale  
        android:fromXScale="1.0"  
        android:toXScale="2.0"  
        android:fromYScale="1.0"  
        android:toYScale="2.0"  
        android:pivotX="0.5"  
        android:pivotY="50%"  
        android:duration="2000"/>  
    <alpha  
        android:fromAlpha="0.0"  
        android:toAlpha="1.0"  
        android:duration="3000"/>  
</set>  


动画定义文件/res/anim/rotate.xml如下:
[html] view plaincopy
<?xml version="1.0" encoding="utf-8"?>  
<set xmlns:android="http://schemas.android.com/apk/res/android"  
    android:interpolator="@android:anim/accelerate_decelerate_interpolator">  
    <rotate  
        android:fromDegrees="0"  
        android:toDegrees="+360"  
        android:pivotX="50%"  
        android:pivotY="50%"  
        android:duration="5000"/>  
</set>  




下面是几种常见的插值器:

Interpolator对象资源ID功能作用
AccelerateDecelerateInterpolator@android:anim/accelerate_decelerate_interpolator先加速再减速
AccelerateInterpolator@android:anim/accelerate_interpolator加速
AnticipateInterpolator@android:anim/anticipate_interpolator先回退一小步然后加速前进
AnticipateOvershootInterpolator@android:anim/anticipate_overshoot_interpolator在上一个基础上超出终点一小步再回到终点
BounceInterpolator@android:anim/bounce_interpolator最后阶段弹球效果
CycleInterpolator@android:anim/cycle_interpolator周期运动
DecelerateInterpolator@android:anim/decelerate_interpolator减速
LinearInterpolator@android:anim/linear_interpolator匀速
OvershootInterpolator@android:anim/overshoot_interpolator快速到达终点并超出一小步最后回到终点

然后我们可以这样使用一个插值器:

[html]  view plain copy
  1. <set android:interpolator="@android:anim/accelerate_interpolator">  
  2. ...  
  3. </set>  
[html]  view plain copy
  1. <alpha android:interpolator="@android:anim/accelerate_interpolator"  
  2.     .../>  



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值