Android的按钮没反应动画后 [英] Android Button Doesn't Respond After Animation

查看:169
本文介绍了Android的按钮没反应动画后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮后,它在我的应用程序目前pssed $ P $的一个基本的动画。之后按钮完成动画,我不能再点击它。它甚至没有preSS一个橙色的亮点。

任何帮助吗?

下面是我的code:

 公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);

动画=新AnimationSet(真正的);
animation.setFillAfter(真正的);
动画翻译=新TranslateAnimation(Animation.RELATIVE_TO_SELF,0.0,Animation.RELATIVE_TO_SELF,0.0,Animation.RELATIVE_TO_SELF,0.0,Animation.RELATIVE_TO_SELF,5.0F);
translate.setDuration(500);
animation.addAnimation(翻译);

LayoutAnimationController控制器=新LayoutAnimationController(动画,0.25f);


产生=(按钮)findViewById(R.id.Button01);

generate.setOnClickListener(新View.OnClickListener(){
    公共无效的onClick(视图v){
            keyFromTop();

        }
    });


}

公共无效keyFromTop(){
    generate.setAnimation(动画);
}
 

解决方案

动画影响的部件只有图纸,这意味着动画完成后,你的按钮仍处于previous位置。您需要手动更新按钮的布局参数,如果你想将它移动到新位置。另外,你的AnimationSet和你AnimationController是无用的。

I have a basic animation of a button after it is pressed currently in my application. After the button finishes animating, I can no longer click on it. It doesn't even press with an orange highlight.

Any help?

Here's my code:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

animation = new AnimationSet(true);
animation.setFillAfter(true);
Animation translate = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 5.0f);
translate.setDuration(500);
animation.addAnimation(translate);

LayoutAnimationController controller = new LayoutAnimationController(animation, 0.25f);


generate = (Button)findViewById(R.id.Button01);

generate.setOnClickListener(new View.OnClickListener(){
    public void onClick(View v){
            keyFromTop();

        }
    });


}

public void keyFromTop(){   
    generate.setAnimation(animation);    
}

解决方案

Animations affect only the drawing of widgets, which means after the animation is done, your button is still at its previous location. You need to manually update the layout parameters of your button if you want to move it to the new location. Also, your AnimationSet and your AnimationController are useless.

这篇关于Android的按钮没反应动画后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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