我需要在imageview中振动图像
为此我用过
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="70"
android:fromDegrees="-5"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="5"
android:repeatMode="reverse"
android:interpolator="@android:anim/linear_interpolator"
android:toDegrees="5" />
<translate
android:fromXDelta="-10"
android:toXDelta="10"
android:repeatCount="5"
android:repeatMode="reverse"
android:interpolator="@android:anim/linear_interpolator"
android:duration="70" />
</set>
实施类似
Animation shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.testanimation);
findViewById(R.id.imgview).startAnimation(shake);
正常工作..但我想在imageview触摸时抖动图像并在用户触摸imageview时停止抖动
imgview.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
System.out.println(event.getAction());
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
//WANT VIBRATEING/SHAKEING IMAGE
break;
case MotionEvent.ACTION_UP:
//WANT TO STOP VIBRATEING/SHAKING IMAGE
break;
}
break;
}
如何使它成为可能? 谢谢, Pragna
答案 0 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="100"
android:fromDegrees="-5"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:toDegrees="5" />