Android--Animation

一、animation

                   RotateAnimationScaleAnimationTranslateAnimation

1RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)

参数说明:角度从多少度到多少度,注意是旋转角度;

旋转的中心的确定,是相对于控件的左上角那个点的座标 加上系数

 如:

RotateAnimation rotateAnimation = new RotateAnimation(

90, 360,//从旋转了90度后开始,开始转到360

Animation.RELATIVE_TO_PARENT, 2f,//相对于自己左上角座标,加上自己1倍宽

Animation.RELATIVE_TO_PARENT, 0f //相对于自己左上角座标,加上自己0倍宽

)


2ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)

ScaleAnimation scaleAnimation = new ScaleAnimation(

1, 0.1f, //x缩放的系数(倍数,从多少倍放到多少倍)

1, 0.1f, //y缩放的系数(倍数,从多少倍放到多少倍)

Animation.RELATIVE_TO_PARENT, 0.5f,//相对于父控件左上角座标,加上父控件的0.5倍宽

Animation.RELATIVE_TO_SELF, 0.5f); //相对于自己左上角座标,加上自己0.5倍宽


3TranslateAnimation移动动画

TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)

全遵循相对控件的左上角坐标 加上系数倍数后的坐标

TranslateAnimation translateAnimation = new TranslateAnimation(

                  Animation.RELATIVE_TO_SELF, 0f,

                  Animation.RELATIVE_TO_SELF, 0.5f,

                  Animation.RELATIVE_TO_SELF, 0f,

                  Animation.RELATIVE_TO_SELF, 1.0f

)


4.添加动画开始和完成的事件

TranslateAnimation tmpAnimation = new TranslateAnimation(midLinearlayout.getLeft(),midLinearlayout.getLeft(),midLinearlayout.getTop(),midLinearlayout.getTop()+100);

//tmpAnimation.setFillAfter(true);

tmpAnimation.setDuration(2000);
tmpAnimation.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                        //To change body of implemented methods use File | Settings | File Templates.
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                            
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                        //To change body of implemented methods use File | Settings | File Templates.
                    }
                });

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值