android 按键上浮动画,Android的按键与动画同步时序

I need an advice how to create some animations I want to add in my buttons. Actually I have the animation code, the thing which I need is how to set properly the timing of each one. Here is what I tried already :

fest.setVisibility(View.INVISIBLE);

handler.postDelayed(new Runnable() {

@Override

public void run() {

fest.setVisibility(View.VISIBLE);

fest.startAnimation(anim);

handler.removeCallbacks(this);

}

}, 500);

This is the things which I did for 7 buttons. First I set the visibility to invisible because I want to achieve the effect that they are appearing after 5 miliseconds after onCreate and for every next button I am increasing the delay time with 5 miliseconds so every of them to appear after the previos one. But the problem in this code is that when the next handler starts for the second button for example, the previos button is getting invisible for a part of the seconds and shows again(I hope someone understand what I mean).

Any suggestions for a bette implementation of something like that?

Thanks in advance!

解决方案

So here is the thing which fixed that problem. I used this for every button and it's working as I want :

final Handler festHandler = new Handler();

festHandler.postDelayed(new Runnable() {

@Override

public void run() {

Animation anim = AnimationUtils.loadAnimation(Menu.this, R.anim.fadein);

fest.setVisibility(View.VISIBLE);

fest.startAnimation(anim);

festHandler.removeCallbacks(this);

}

}, 400);

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值