简体   繁体   English

RotateAnimation之后的Android setOnClickListener

[英]Android setOnClickListener after RotateAnimation

In 2.2 SDK I'm rotating a TextView and I've attached an onClickListener to display a dummy text in console, but the onClick method isn't fired. 在2.2 SDK中,我旋转了TextView,并附加了onClickListener以便在控制台中显示虚拟文本,但不会触发onClick方法。 Is something wrong with my code, or there is a workaround? 我的代码有问题吗,或者有解决方法?

public void setTextViewRotation(int angle, TextView tv) {
    RotateAnimation rayAnim = new RotateAnimation(0, angle - 90, -100, 22);
    rayAnim.setFillAfter(true);
    rayAnim.setDuration(1);
    rayAnim.setAnimationListener(this);
    tv.setAnimation(rayAnim);
}
... textView declaration...setTextViewRotation(angle, textView);
... textView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("Main","select ray");
            }
        });

It happens when you apply animation to any component. 当您将动画应用于任何组件时,就会发生这种情况。

In your case may be you are clicking on new position of textview. 在您的情况下,您可能正在单击textview的新位置。

It shows that you have moved that component. 它表明您已经移动了该组件。

But actually that components retains its original position . 但是实际上,这些组件保留了其原始位置

It does not moves from his original position. 它不会偏离他的原始位置。

You can say its android limitation. 您可以说它的android限制。

But now it is solved in API level 3.0 但现在在API级别3.0中已解决

You can try 3.0 or above. 您可以尝试3.0或更高版本。 for more read this 有关更多信息,请阅读

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM