There is such an animation:
android:duration="100" android:fillBefore="false" android:fromXScale="1.0" android:fromYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:startOffset="0" android:toXScale="0.9" android:interpolator="@android:anim/decelerate_interpolator" android:toYScale="0.9" /> How it works: the object is first reduced, and then returned to its original state. (ImageView object)
In the code I address so:
anim= AnimationUtils.loadAnimation(getContext(),R.anim.clickbutton); and call it like this:
public boolean onTouch(View v, MotionEvent event) { v.startAnimation(anim); switch (v.getId()) { case R.id.b1: { stopPlayerIfNeeded(); playSample(soundsRawResIds[0]); } break; Everything works like a clock, but I would like the animation to "work constantly" after clicking. I clicked on case R.id.b1 - the action was performed, but the animation continued to work until I chose another R.id.* and further
///////////////////////////////////////// how to stop the animation in this case? right now : chose R.id.b1: everything started and works, chose R.id.b2: the animation started but also on R.id.b1: the animation continues to run, but you need to stop
for (int j = 0; j < arr_imageB.length; j++) { arr_imageB[j].setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.startAnimation(anim); switch (v.getId()) { case R.id.b1: { stopPlayerIfNeeded(); playSample(soundsRawResIds[0]); } break; case R.id.b2: { stopPlayerIfNeeded(); playSample(soundsRawResIds[1]); } break; case R.id.b3: { stopPlayerIfNeeded(); playSample(soundsRawResIds[2]); } break; case R.id.b4: { stopPlayerIfNeeded(); playSample(soundsRawResIds[3]); } break; case R.id.b5: { stopPlayerIfNeeded(); playSample(soundsRawResIds[4]); } break; case R.id.b6: { stopPlayerIfNeeded(); playSample(soundsRawResIds[5]); } break; case R.id.b7: { stopPlayerIfNeeded(); playSample(soundsRawResIds[6]); } break; }