2012-10-11 28 views
1

在2.2 SDK中我旋轉了一個TextView,並附加了一個onClickListener在控制檯中顯示一個虛擬文本,但是onClick方法沒有被觸發。我的代碼有問題,或者有解決方法?RotateAnimation之後的Android setOnClickListener

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"); 
      } 
     }); 
+1

請確定您已經在xml佈局中爲textView添加了'android:clickable =「true」'? –

+0

textView已經可以點擊了......如果我刪除旋轉動畫,它可以工作 – dorin

回答

0

將動畫應用到任何組件時會發生這種情況。

在你的情況可能是你點擊textview的新位置。

它顯示您已移動該組件。

但實際上是部件保留其原來的位置

它不會從原來的位置移動。

你可以說它的android限制。

但現在它在API級別3.0

解決您可以嘗試3.0或以上。更多閱讀this