I have ImageView
moving on the screen, I need to execute an animation when it is touched by the user, however image.setOnClickListener
and also image.onTouchListener
are not being activated when the image is clicked.
res / anim / translate.xml
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/decelerate_quad"
android:fromXDelta="-100%"
android:toXDelta="0%"
android:fromYDelta="0%"
android:toYDelta="0%"
android:duration="2000"
android:zAdjustment="top" />
activity that contains animation start
private void IniciarAnimacoes() {
//Animaçoes dos pinguins
anim = AnimationUtils.loadAnimation(this, R.anim.movimento_pinguim);
anim.reset();
imgPiguim = (ImageView) findViewById(R.id.imgPinguim);
imgPiguim.setBackgroundResource(R.drawable.background_pinguim_anima);
animaPiguim = (AnimationDrawable)imgPiguim.getBackground();
imgPiguim.clearAnimation();
imgPiguim.startAnimation(anim);
In the code the penguin jumps on the screen, I need it when the user touches it at some point to trigger an event.
Can anyone help me with this, with some example or what other parameters should be used?