Android的按钮没反应动画后按钮、反应、动画、Android

2023-09-04 04:24:19 作者:昵称虽然是一个网络上的虚拟名字,但很多人还是会在意好不好听,

我有一个按钮后,它在我的应用程序目前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是无用的。

Android 修改标题栏和创建按钮

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.