同时播放动画的android按钮无法点击 [英] android button not clickable while playing animations

查看:397
本文介绍了同时播放动画的android按钮无法点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,此按钮时播放的动画,我不能点击按钮。我已经设置点击监听器和触摸监听器,但在调试模式下它不进入的OnClick和onTouch方法。你知道为什么吗?谢谢

I have a button and while this button is playing an animation, I'm not able to click on button. I've set click listener and touch listener but in debug mode it's not entering in OnClick and in onTouch methods. Do you know why? Thanks

编辑:我想是这样:

        AsyncTask task = new AsyncTask() {

        @Override
        protected Object doInBackground(Object... objects) {
            button1.setOnClickListener(new View.OnClickListener() {

                public void onClick(View view) {
                    Toast toast = Toast.makeText(MyActivity.this, button1.getText(), Toast.LENGTH_SHORT);
                    toast.show();
                }
            });
            return null;
        }

        ;
    };
    task.execute(button1);

,但它不工作

but it's not working

编辑:这里是完整的源$ C ​​$ C

推荐答案

的Andr​​oid 3.0之前,使用任何动画类的只有改变,其视图绘制 - 在(或之后),它不会调整其触摸界的动画: <一href="http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html">http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html

Before Android 3.0, using any of the animation classes only changes where the view is drawn - it won't adjust its touchable-bounds during (or after) the animation: http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html

您可以:

  • 请一个的ViewGroup地移动它的孩子每天的OnDraw
  • 覆盖您的视图的OnDraw移动本身 - 能否用保证金或填充,或者位置(如果视图在一个的FrameLayout或类似的东西)
  • 在仅使用3.0或更高版本的设备
  • 重写父的onTouch(或onInterceptTouchEvent),计算出在哪里查看被绘制(你可以走多远进,从动画*实际位置的偏移量)和相应处理...... *寻找你的code(因为你生成每次完成一次任意方向),这也许是不可能的,没有你已经previously采取何种方向追踪。

这篇关于同时播放动画的android按钮无法点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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