Anyone here know how to make the imageview clickable during translate animation?
In my code below, the animation is working very well but only the click. Can't click on ImageView during animation but can click on ImageView on the position that ImageView located at the first start.
My translation xml:
<translate
android:duration="10000"
android:fromXDelta="0%p" android:toXDelta="0%p" android:fillEnabled="true"
android:fromYDelta="-15%p" android:toYDelta="110%p"/>
My Anin Activity:
public class play_1 extends Activity implements AnimationListener {
private ImageView ant_play_1;
AnimationDrawable walking_1;
Animation translate_play_1;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.play);
ant_play_1 = (ImageView) findViewById(R.id.ant_play_1);
ant_play_1.setBackgroundResource(R.drawable.walking_play_1);
walking_1 = (AnimationDrawable) ant_play_1.getBackground();
walking_1.start();
translate1();
}
public void translate1()
{
translate_play_1 = AnimationUtils.loadAnimation(this, R.anim.translate_play_1);
ant_play_1.startAnimation(translate_play_1);
translate_play_1.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationStart(Animation animation) { }
@Override
public void onAnimationRepeat(Animation animation) { }
@Override
public void onAnimationEnd(Animation animation) { translate1(); }
});
ant_play_1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
Toast.makeText(play_1.this, "Translation Can Click Now!", Toast.LENGTH_SHORT).show();
}
});
}
}