我有一个带有一些按钮的相对布局,我创建了一个旋转动画来旋转它
但是当我旋转它时按钮的 Action 不能正常工作,按钮的 Action 仍然保存旋转前按钮的旧位置
谁能帮我解决这个问题
<ImageButton
android:id="@+id/last20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="75dp"
android:background="@null"
android:src="@drawable/last20_selector"
android:onClick="last20OnClick"/>
super.onCreate(savedInstanceState);
setContentView(R.layout.wheel);
RelativeLayout layout = (RelativeLayout) findViewById(R.id.wheelLayout);
RotateAnimation rotateAnim = new RotateAnimation(0, 45,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
rotateAnim.setDuration(1000);
rotateAnim.setRepeatCount(0);
rotateAnim.setFillAfter(true);
layout.startAnimation(rotateAnim);
}
public void last20OnClick(View view) {
System.out.println("last20OnClick");
}
最佳答案
尝试设置属性:
android:fillAfter="false"
android:fillBefore="false"
或者在java中:
rotateAnim.setFillAfter(false);
rotateAnim.setFillBefore(false);
如本 question 中所建议.它帮助了我。 另外,为了保持您的动画从 -45 度旋转到 0 度。
关于android - 旋转后按钮 Action 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9549844/