悬浮按钮显示隐藏动画(补间动画)



public void AnimR(){
    if(null == taR) {
        taR = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0.9f, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
        taR.setDuration(200);
        taR.setFillAfter(true);
        alO = new AlphaAnimation(1, 0.2f); //0表示完全透明。1表示不透明
        alO.setDuration(200);
        alO.setFillAfter(true);
        setR = new AnimationSet(false);
        setR.addAnimation(taR);
        setR.addAnimation(alO);
        setR.setFillAfter(true);
    }
    iv_fast_appoint.startAnimation(setR); //iv表示动画显示显示在哪个地方 通过findviewbyid拿到

}
public void AnimL(){
    if(null == taL) {
        taL = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.9f, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);taL.setDuration(200);
        taL.setFillAfter(true);
        taL.setDuration(200);
        alT = new AlphaAnimation(0.2f, 1); //0表示完全透明。1表示不透明
        alT.setDuration(200);
        alT.setFillAfter(true);
        setL = new AnimationSet(false);
        setL.addAnimation(taL);
        setL.addAnimation(alT);
        setL.setFillAfter(true);
    }
    iv_fast_appoint.startAnimation(setL); //iv表示动画显示显示在哪个地方 通过findviewbyid拿到
    setL.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            canSrcollR = true;
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
}

动画延迟的话可以通过

setStartOffset这个方法设置动画延迟时间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值