2
I have a ImageView
moving on the screen, I need to perform an animation when it is touched by the user, but 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 the start of the animation
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 keeps jumping on the screen, I need that when the user touches it sometime trigger an event.
Could someone help me with this, with some example or what other parameters should be used?
because then that’s exactly how I’m doing, and the event does not respond in the image that’s in motion
– Roger Casagrande
You already said that in the question so before answering, I tested the code and it works.
– ramaral