转换后的动画按钮单击不起作用

转换后的动画按钮单击不起作用,第1张

概述当我单击一个按钮时,翻译动画开始.然后将按钮放置在翻译动画结束的位置.它工作正常,但是在动画按钮单击后不起作用.提前致谢publicclassButtonFragmentextendsActivityimplementsOnClickListener{privateButtonbtn;privateintwidth;privateBooleanflag=true;

当我单击一个按钮时,翻译动画开始.然后将按钮放置在翻译动画结束的位置.它工作正常,但是在动画按钮单击后不起作用.
提前致谢

public class buttonFragment extends Activity  implements OnClickListener{private button btn;private int wIDth;private Boolean flag = true;@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentVIEw(R.layout.activity_button_fragment);    display display = getwindowManager().getDefaultdisplay();    Point size = new Point();    display.getSize(size);    wIDth = size.x;    btn = (button) findVIEwByID(R.ID.btn);    btn.setonClickListener(this);}@OverrIDepublic voID onClick(VIEw v) {    TranslateAnimation animation = null;    switch (v.getID()) {    case R.ID.btn:        if(flag ==  true) {                         animation = new TranslateAnimation(0, wIDth-92 , 0, 0);            flag=false;        }        else{            animation = new TranslateAnimation(wIDth-92,0 , 0, 0);            flag = true;        }        animation.setDuration(1000);        animation.setFillAfter(true);        btn.startAnimation(animation);        break;    default:        break;    }  }           }

代码正确对齐

解决方法:

如this page中所述:

Another disadvantage of the vIEw animation system is that it only modifIEd where the VIEw was drawn, and not the actual VIEw itself. For instance, if you animated a button to move across the screen, the button draws correctly, but the actual location where you can click the button does not change, so you have to implement your own logic to handle this.

尝试使用属性动画并阅读上面给出的链接.

总结

以上是内存溢出为你收集整理的转换后的动画按钮单击不起作用全部内容,希望文章能够帮你解决转换后的动画按钮单击不起作用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1077818.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存