我正在尝试在其中心旋转图像视图。当我点击图像时,它不会旋转。有什么理由吗?
refreshResults.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RotateAnimation anim = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
//how to start it.
refreshResults.startAnimation(anim);
}
});
答案 0 :(得分:1)
试试这个为我工作。
RotateAnimation myAnim = new RotateAnimation(0, 45, Animation.RELATIVE_TO_SELF,
0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
myAnim .setInterpolator(new LinearInterpolator());
myAnim .setDuration(500);
myAnim .setFillEnabled(true);
myAnim .setFillAfter(true);
image.startAnimation(myAnim )