Android的按键与动画同步时序 [英] Android button animations synchronize with timing

查看:144
本文介绍了Android的按键与动画同步时序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个建议如何创造一些动画我想在我的添加按钮。其实我有动画code,这是我需要的是如何正确地设置每一个时间的事情。以下是我已经试过:

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);

这是我做了7个按键的事情。首先,我的可见性设置为不可见的,因为我想要实现它们后的onCreate 并为每一个按钮后,5毫秒出现,我用5毫秒增加延迟时间的影响所以每次他们到previos相继出现。但是在这个code中的问题是,当一个处理开始的例如第二个按钮,在previos按钮为秒的一部分,越来越看不见,再次表明(我希望有人明白我的意思)

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?

在此先感谢!

推荐答案

因此​​,这里是一个固定的问题的东西。我用这对每一个按钮,它的工作,因为我想:

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);

这篇关于Android的按键与动画同步时序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆