I am attempting to set an on clickListener on a image view as it is animating. The ImageView is moving from the bottom of the screen to the top. However, when the imageView is at the bottom of the screen and I touch the top of the screen it allows it to be clicked. I only want where the imageview is to be clicked and not other locations in its path.
Animation in xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromYDelta="75%p"
android:toYDelta="0%p"
android:duration="5000"
android:repeatCount="infinite"/>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="5000"
android:fromXScale="1.4"
android:fromYScale="1.4"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale=".6"
android:toYScale=".6"
android:repeatCount="infinite">
</scale>
</set>
The code
mBalloonPortrait1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MediaPlayer mediaPlayer = MediaPlayer.create(MainBalloonActivity.this,
mBalloonArrayList.get(0).getAudioId());
mediaPlayer.start();
balloonFallAndFloat(mBalloonPortrait1);
}
});
private void balloonFallAndFloat(final ImageView balloon){
Thread thread = new Thread() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
balloon.startAnimation(AnimationUtils.loadAnimation(
getApplicationContext(), R.anim.start_game_animation));
}
});
}
};
thread.start();
}